mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
ScatterDraw: PLot responsiveness and 2D surfaces added.
git-svn-id: svn://ultimatepp.org/upp/trunk@12443 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
c77bad486f
commit
df766447f5
18 changed files with 9830 additions and 1989 deletions
|
|
@ -661,4 +661,400 @@ bool DataSource::SameX(DataSource &data) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void TableData::Init(Vector<double> &data, Vector<double> &xAxis, Vector<double> &yAxis,
|
||||
Interpolate inter, bool areas) {
|
||||
ASSERT(areas ? (data.GetCount() == (xAxis.GetCount() - 1)*(yAxis.GetCount() - 1)) : true);
|
||||
ASSERT(!areas ? (data.GetCount() == xAxis.GetCount()*yAxis.GetCount()) : true);
|
||||
this->pdata = &data;
|
||||
this->pxAxis = &xAxis;
|
||||
this->pyAxis = &yAxis;
|
||||
this->inter = inter;
|
||||
this->areas = areas;
|
||||
}
|
||||
|
||||
|
||||
double BilinearInterpolate(double x, double y, double x1, double x2, double y1, double y2,
|
||||
double z11, double z12, double z21, double z22) {
|
||||
double x_x1 = x - x1;
|
||||
double x2_x = x2 - x;
|
||||
double y_y1 = y - y1;
|
||||
double y2_y = y2 - y;
|
||||
return (z11*x2_x*y2_y + z21*x_x1*y2_y + z12*x2_x*y_y1 + z22*x_x1*y_y1)/(x2 - x1)/(y2 - y1);
|
||||
}
|
||||
|
||||
double TableData::z_area(double x, double y) {
|
||||
if (inter == NO) {
|
||||
int ix, iy;
|
||||
for (ix = 0; ix < pxAxis->GetCount(); ++ix) {
|
||||
if ((*pxAxis)[ix] > x) {
|
||||
if (ix == 0)
|
||||
return Null;
|
||||
else {
|
||||
ix--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ix == pxAxis->GetCount())
|
||||
return Null;
|
||||
for (iy = 0; iy < pyAxis->GetCount(); ++iy) {
|
||||
if ((*pyAxis)[iy] > y) {
|
||||
if (iy == 0)
|
||||
return Null;
|
||||
else {
|
||||
iy--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (iy == pyAxis->GetCount())
|
||||
return Null;
|
||||
return (*pdata)[ix + iy*(pxAxis->GetCount() - 1)];
|
||||
} else if (inter == BILINEAR) {
|
||||
int ix, iy;
|
||||
for (ix = 0; ix < pxAxis->GetCount()-1; ++ix) {
|
||||
if ((((*pxAxis)[ix]+(*pxAxis)[ix+1])/2.) > x) {
|
||||
if (ix == 0)
|
||||
return Null;
|
||||
else {
|
||||
ix--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ix == pxAxis->GetCount()-1)
|
||||
return Null;
|
||||
for (iy = 0; iy < pyAxis->GetCount()-1; ++iy) {
|
||||
if ((((*pyAxis)[iy]+(*pyAxis)[iy+1])/2.) > y) {
|
||||
if (iy == 0)
|
||||
return Null;
|
||||
else {
|
||||
iy--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (iy == pyAxis->GetCount()-1)
|
||||
return Null;
|
||||
|
||||
int width = pxAxis->GetCount() - 1;
|
||||
double x1 = ((*pxAxis)[ix] + (*pxAxis)[ix+1])/2.;
|
||||
double x2 = ((*pxAxis)[ix+1] + (*pxAxis)[ix+2])/2.;
|
||||
double y1 = ((*pyAxis)[iy] + (*pyAxis)[iy+1])/2.;
|
||||
double y2 = ((*pyAxis)[iy+1] + (*pyAxis)[iy+2])/2.;
|
||||
double z11 = (*pdata)[ix + iy*width];
|
||||
double z12 = (*pdata)[ix + (iy+1)*width];
|
||||
double z21 = (*pdata)[ix+1+ iy*width];
|
||||
double z22 = (*pdata)[ix+1 + (iy+1)*width];
|
||||
if (IsNull(z11) || IsNull(z12) || IsNull(z21) || IsNull(z22))
|
||||
return Null;
|
||||
return BilinearInterpolate(x, y, x1, x2, y1, y2, z11, z12, z21, z22);
|
||||
} else
|
||||
return Null;
|
||||
}
|
||||
|
||||
double TableData::z_point(double x, double y) {
|
||||
if (x < (*pxAxis)[0] || x > pxAxis->Top() ||
|
||||
y < (*pyAxis)[0] || y > pyAxis->Top())
|
||||
return Null;
|
||||
|
||||
if (inter == NO) {
|
||||
int ix, iy;
|
||||
if (x < ((*pxAxis)[0] + (*pxAxis)[1])/2.)
|
||||
ix = 0;
|
||||
else if (x >= ((*pxAxis)[pxAxis->GetCount()-1] + (*pxAxis)[pxAxis->GetCount()-2])/2.)
|
||||
ix = pxAxis->GetCount()-1;
|
||||
else {
|
||||
for (ix = 1; ix < pxAxis->GetCount()-1; ++ix) {
|
||||
if (((*pxAxis)[ix] + (*pxAxis)[ix+1])/2. > x)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (y < ((*pyAxis)[0] + (*pyAxis)[1])/2.)
|
||||
iy = 0;
|
||||
else if (y >= ((*pyAxis)[pyAxis->GetCount()-1] + (*pyAxis)[pyAxis->GetCount()-2])/2.)
|
||||
iy = pyAxis->GetCount()-1;
|
||||
else {
|
||||
for (iy = 1; iy < pyAxis->GetCount()-1; ++iy) {
|
||||
if (((*pyAxis)[iy] + (*pyAxis)[iy+1])/2. > y)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (*pdata)[ix + iy*pxAxis->GetCount()];
|
||||
} else if (inter == BILINEAR) {
|
||||
int ix, iy;
|
||||
for (ix = 0; ix < pxAxis->GetCount()-1; ++ix) {
|
||||
if ((*pxAxis)[ix+1] >= x)
|
||||
break;
|
||||
}
|
||||
if (ix == pxAxis->GetCount()-1)
|
||||
return Null;
|
||||
for (iy = 0; iy < pyAxis->GetCount()-1; ++iy) {
|
||||
if ((*pyAxis)[iy+1] >= y)
|
||||
break;
|
||||
}
|
||||
if (iy == pyAxis->GetCount()-1)
|
||||
return Null;
|
||||
int width = pxAxis->GetCount();
|
||||
double x1 = (*pxAxis)[ix];
|
||||
double x2 = (*pxAxis)[ix+1];
|
||||
double y1 = (*pyAxis)[iy];
|
||||
double y2 = (*pyAxis)[iy+1];
|
||||
double z11 = (*pdata)[ix + iy*width];
|
||||
double z12 = (*pdata)[ix + (iy+1)*width];
|
||||
double z21 = (*pdata)[ix+1 + iy*width];
|
||||
double z22 = (*pdata)[ix+1 + (iy+1)*width];
|
||||
if (IsNull(z11) || IsNull(z12) || IsNull(z21) || IsNull(z22))
|
||||
return Null;
|
||||
return BilinearInterpolate(x, y, x1, x2, y1, y2, z11, z12, z21, z22);
|
||||
} else
|
||||
return Null;
|
||||
}
|
||||
|
||||
double TableData::z(double x, double y) {
|
||||
if (areas)
|
||||
return z_area(x, y);
|
||||
else
|
||||
return z_point(x, y);
|
||||
}
|
||||
|
||||
bool TableData::IsEmpty() {
|
||||
if (!pdata || !pxAxis || !pyAxis)
|
||||
return true;
|
||||
return pdata->IsEmpty() || pxAxis->IsEmpty() || pyAxis->IsEmpty();
|
||||
}
|
||||
|
||||
double TableData::MinX() {
|
||||
return (*pxAxis)[0];
|
||||
}
|
||||
|
||||
double TableData::MaxX() {
|
||||
return pxAxis->Top();
|
||||
}
|
||||
|
||||
double TableData::MinY() {
|
||||
return (*pyAxis)[0];
|
||||
}
|
||||
|
||||
double TableData::MaxY() {
|
||||
return pyAxis->Top();
|
||||
}
|
||||
|
||||
double TableData::MinZ() {
|
||||
Vector<double> &data = *pdata;
|
||||
double ret = -DOUBLE_NULL;
|
||||
for (int i = 0; i < data.GetCount(); ++i) {
|
||||
double &d = data[i];
|
||||
if (!IsNull(d)) {
|
||||
if (ret > d)
|
||||
ret = d;
|
||||
}
|
||||
}
|
||||
if (ret == -DOUBLE_NULL)
|
||||
return Null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
double TableData::MaxZ() {
|
||||
Vector<double> &data = *pdata;
|
||||
double ret = DOUBLE_NULL;
|
||||
for (int i = 0; i < data.GetCount(); ++i) {
|
||||
double &d = data[i];
|
||||
if (!IsNull(d)) {
|
||||
if (ret < d)
|
||||
ret = d;
|
||||
}
|
||||
}
|
||||
if (ret == DOUBLE_NULL)
|
||||
return Null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ExplicitData::Init(Function<double (double x, double y)> funz, double minX, double maxX, double minY, double maxY) {
|
||||
ASSERT(maxX >= minX && maxY >= minY);
|
||||
this->funz = funz;
|
||||
this->minX = minX;
|
||||
this->maxX = maxX;
|
||||
this->minY = minY;
|
||||
this->maxY = maxY;
|
||||
|
||||
minZ = -DOUBLE_NULL_LIM;
|
||||
maxZ = DOUBLE_NULL_LIM;
|
||||
double deltax = (maxX - minX)/100.;
|
||||
double deltay = (maxY - minY)/100.;
|
||||
for (double x = minX; x <= maxX; x += deltax) {
|
||||
for (double y = minY; y <= maxY; y += deltay) {
|
||||
double z = funz(x, y);
|
||||
if (!IsNull(z)) {
|
||||
minZ = min(minZ, z);
|
||||
maxZ = max(maxZ, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int FindClosest(Pointf &p, Vector<Pointf> &points, double deltaX, double deltaY, double &d) {
|
||||
double dxmin = -DOUBLE_NULL, dymin = -DOUBLE_NULL;
|
||||
int imin = -1;
|
||||
for (int i = 0; i < points.GetCount(); ++i) {
|
||||
double dx = abs(p.x - points[i].x);
|
||||
double dy = abs(p.y - points[i].y);
|
||||
if (dx*dx + dy*dy < dxmin*dxmin + dymin*dymin) {
|
||||
dxmin = dx;
|
||||
dymin = dy;
|
||||
imin = i;
|
||||
}
|
||||
}
|
||||
if ((dxmin > deltaX*1.00000000001) || (dymin > deltaY*1.00000000001))
|
||||
return Null;
|
||||
d = sqrt(dxmin*dxmin + dymin*dymin);
|
||||
return imin;
|
||||
}
|
||||
|
||||
Vector<Pointf> DataSourceSurf::GetIsolines(const Vector<double> &vals, const Rectf &area, double deltaX, double deltaY) {
|
||||
Vector<Pointf> isolines;
|
||||
for (int i = 0; i < vals.GetCount(); ++i) {
|
||||
if (i > 0)
|
||||
isolines << Null;
|
||||
Vector<Pointf> isoaux = GetIsoline(vals[i], area, deltaX, deltaY);
|
||||
isolines.Append(isoaux);
|
||||
}
|
||||
return isolines;
|
||||
}
|
||||
|
||||
Vector<Pointf> DataSourceSurf::GetIsoline(double thres, const Rectf &area, double deltaX, double deltaY) {
|
||||
Vector<double> zp;
|
||||
|
||||
int width = (int)(area.GetWidth()/deltaX) + 1;
|
||||
int height = -(int)(area.GetHeight()/deltaY) + 1;
|
||||
zp.SetCount(width*height);
|
||||
int iy = 0;
|
||||
for (double y = area.bottom; iy < height; y += deltaY, iy++) {
|
||||
int ix = 0;
|
||||
for (double x = area.left; ix < width; x += deltaX, ix++)
|
||||
zp[ix + iy*width] = z(x, y);
|
||||
}
|
||||
|
||||
Vector<Pointf> points;
|
||||
for (int iy = 0; iy < height; iy++) {
|
||||
for (int ix = 0; ix < width-1; ix++) {
|
||||
double z0 = zp[ix + iy*width];
|
||||
double z1 = zp[ix+1 + iy*width];
|
||||
if (IsNull(z0) || IsNull(z1))
|
||||
continue;
|
||||
if ((z1 > thres && z0 <= thres) || (z0 > thres && z1 <= thres)) {
|
||||
double delta = abs(thres - z0)/abs(z1 - z0);
|
||||
points << Pointf(area.left + (ix + delta)*deltaX, area.bottom + iy*deltaY);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int ix = 0; ix < width; ix++) {
|
||||
for (int iy = 0; iy < height-1; iy++) {
|
||||
double z0 = zp[ix + iy*width];
|
||||
double z1 = zp[ix + (iy+1)*width];
|
||||
if (IsNull(z0) || IsNull(z1))
|
||||
continue;
|
||||
if ((z1 > thres && z0 <= thres) || (z0 > thres && z1 <= thres)) {
|
||||
double delta = abs(thres - z0)/abs(z1 - z0);
|
||||
points << Pointf(area.left + ix*deltaX, area.bottom + (iy + delta)*deltaY);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (points.IsEmpty())
|
||||
return points;
|
||||
|
||||
Vector<Pointf> isoline;
|
||||
isoline << points[0];
|
||||
points.Remove(0);
|
||||
while (!points.IsEmpty()) {
|
||||
int imin;
|
||||
double dt, d0;
|
||||
int iminT = FindClosest(isoline.Top(), points, deltaX, deltaY, dt);
|
||||
int imin0 = FindClosest(isoline[0], points, deltaX, deltaY, d0);
|
||||
if (IsNull(iminT) && IsNull(imin0)) {
|
||||
isoline << Null;
|
||||
imin = 0;
|
||||
} else if (IsNull(iminT)) {
|
||||
Reverse(isoline);
|
||||
imin = imin0;
|
||||
} else if (IsNull(imin0))
|
||||
imin = iminT;
|
||||
else {
|
||||
if (dt > d0) {
|
||||
Reverse(isoline);
|
||||
imin = imin0;
|
||||
} else
|
||||
imin = iminT;
|
||||
}
|
||||
isoline << points[imin];
|
||||
points.Remove(imin);
|
||||
}
|
||||
return isoline;
|
||||
}
|
||||
|
||||
Pointf Intersection(Pointf &a, Pointf &b, Pointf &c, Pointf &d) {
|
||||
// Line AB represented as a1x + b1y = c1
|
||||
double a1 = b.y - a.y;
|
||||
double b1 = a.x - b.x;
|
||||
double c1 = a1*(a.x) + b1*(a.y);
|
||||
|
||||
// Line CD represented as a2x + b2y = c2
|
||||
double a2 = d.y - c.y;
|
||||
double b2 = c.x - d.x;
|
||||
double c2 = a2*(c.x)+ b2*(c.y);
|
||||
|
||||
double det = a1*b2 - a2*b1;
|
||||
|
||||
if (det == 0) // Parallel
|
||||
return Null;
|
||||
else {
|
||||
double x = (b2*c1 - b1*c2)/det;
|
||||
double y = (a1*c2 - a2*c1)/det;
|
||||
return Pointf(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
Pointf SegIntersection(Pointf &a, Pointf &b, Pointf &c, Pointf &d) {
|
||||
Pointf inter = Intersection(a, b, c, d);
|
||||
if (IsNull(inter))
|
||||
return Null;
|
||||
if (((a.x <= inter.x && b.x >= inter.x) || (b.x <= inter.x && a.x >= inter.x)) &&
|
||||
((a.y <= inter.y && b.y >= inter.y) || (b.y <= inter.y && a.y >= inter.y)) &&
|
||||
((c.x <= inter.x && d.x >= inter.x) || (d.x <= inter.x && c.x >= inter.x)) &&
|
||||
((c.y <= inter.y && d.y >= inter.y) || (d.y <= inter.y && c.y >= inter.y)))
|
||||
return inter;
|
||||
return Null;
|
||||
}
|
||||
|
||||
Vector<Pointf> Intersection(Vector<Pointf> &poly1, Vector<Pointf> &poly2) {
|
||||
Vector<Pointf> listInter;
|
||||
for (int i1 = 0; i1 < poly1.GetCount() - 1; ++i1) {
|
||||
for (int i2 = 0; i2 < poly2.GetCount() - 1; ++i2) {
|
||||
Pointf inter = SegIntersection(poly1[i1], poly1[i1+1], poly2[i2], poly2[i2+1]);
|
||||
if (!IsNull(inter)) {
|
||||
bool found = false;
|
||||
for (int i = 0; i < listInter.GetCount(); ++i) {
|
||||
if (abs((inter.x - listInter[i].x)/inter.x) < 0.000001 &&
|
||||
abs((inter.y - listInter[i].y)/inter.y) < 0.000001) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
listInter << inter;
|
||||
}
|
||||
}
|
||||
}
|
||||
return listInter;
|
||||
}
|
||||
|
||||
void Simplify(Vector<Pointf> &poly, double dx, double dy) {
|
||||
for (int i = 1; i < poly.GetCount(); ++i) {
|
||||
if (abs(poly[i].x - poly[i-1].x) < dx && abs(poly[i].y - poly[i-1].y) < dy) {
|
||||
poly.Remove(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ public:
|
|||
typedef double (DataSource::*Getdatafun)(int64 id);
|
||||
|
||||
DataSource() : isParam(false), isExplicit(false), key(111111) {}
|
||||
virtual ~DataSource() {key = 0;}
|
||||
virtual ~DataSource() {key = 0;}
|
||||
virtual double y(int64 id) {/*NEVER();*/ return Null;}
|
||||
virtual double x(int64 id) {/*NEVER();*/ return Null;}
|
||||
virtual double znx(int n, int64 id) {/*NEVER();*/ return Null;}
|
||||
|
|
@ -546,14 +546,14 @@ public:
|
|||
|
||||
class FuncSourcePara : public DataSource {
|
||||
private:
|
||||
Pointf (*function)(double);
|
||||
Function <Pointf(double)> function;
|
||||
Pointf lastPointf;
|
||||
double lastT;
|
||||
int numPoints;
|
||||
double minT, maxT;
|
||||
|
||||
public:
|
||||
FuncSourcePara(Pointf (*function)(double), int np, double from, double to) :
|
||||
FuncSourcePara(Function <Pointf(double)> function, int np, double from, double to) :
|
||||
function(function), numPoints(np), minT(from), maxT(to) {
|
||||
isParam = true;
|
||||
lastT = Null;
|
||||
|
|
@ -576,7 +576,7 @@ public:
|
|||
};
|
||||
|
||||
typedef Event<double&, double> PlotExplicFunc;
|
||||
typedef Event<Pointf&, double> PlotParamFunc;
|
||||
typedef Function<void(Pointf&, double)> PlotParamFunc;
|
||||
|
||||
|
||||
class PlotExplicFuncSource : public DataSource {
|
||||
|
|
@ -623,6 +623,114 @@ struct PointfLess {
|
|||
bool operator () (const Pointf& a, const Pointf& b) const { return a.x < b.x; }
|
||||
};
|
||||
|
||||
class DataSourceSurf {
|
||||
public:
|
||||
DataSourceSurf() : isExplicit(false), key(1212121) {}
|
||||
virtual ~DataSourceSurf() {key = 0;}
|
||||
virtual double z(double x, double y)= 0;
|
||||
|
||||
virtual bool IsEmpty() = 0;
|
||||
bool IsDeleted() {return key != 1212121;}
|
||||
bool IsExplicit() {return isExplicit;}
|
||||
|
||||
virtual double MinX() = 0;
|
||||
virtual double MaxX() = 0;
|
||||
virtual double MinY() = 0;
|
||||
virtual double MaxY() = 0;
|
||||
virtual double MinZ() = 0;
|
||||
virtual double MaxZ() = 0;
|
||||
|
||||
Vector<Pointf> GetIsoline(double thres, const Rectf &area, double deltaX, double deltaY);
|
||||
Vector<Pointf> GetIsolines(const Vector<double> &vals, const Rectf &area, double deltaX, double deltaY);
|
||||
|
||||
protected:
|
||||
bool isExplicit;
|
||||
|
||||
private:
|
||||
int key;
|
||||
};
|
||||
|
||||
class TableData : public DataSourceSurf {
|
||||
public:
|
||||
enum Interpolate {NO, BILINEAR};
|
||||
TableData() : pdata(0), pxAxis(0), pyAxis(0), areas(false) {}
|
||||
TableData(Vector<double> &data, Vector<double> &xAxis, Vector<double> &yAxis,
|
||||
Interpolate inter, bool areas) {Init(data, xAxis, yAxis, inter, areas);}
|
||||
void Init(Vector<double> &data, Vector<double> &xAxis, Vector<double> &yAxis,
|
||||
Interpolate inter, bool areas);
|
||||
|
||||
double z(double x, double y);
|
||||
|
||||
bool IsEmpty();
|
||||
|
||||
double MinX();
|
||||
double MaxX();
|
||||
double MinY();
|
||||
double MaxY();
|
||||
double MinZ();
|
||||
double MaxZ();
|
||||
|
||||
Interpolate Inter() {return inter;}
|
||||
void Inter(Interpolate inter) {this->inter = inter;}
|
||||
|
||||
private:
|
||||
Vector<double> *pdata;
|
||||
Vector<double> *pxAxis;
|
||||
Vector<double> *pyAxis;
|
||||
Interpolate inter;
|
||||
|
||||
double z_area(double x, double y);
|
||||
double z_point(double x, double y);
|
||||
|
||||
protected:
|
||||
bool areas;
|
||||
};
|
||||
|
||||
class TableDataAreas : public TableData {
|
||||
public:
|
||||
TableDataAreas() : TableData() {areas = true;}
|
||||
TableDataAreas(Vector<double> &data, Vector<double> &xAxis, Vector<double> &yAxis,
|
||||
Interpolate inter) {TableData::Init(data, xAxis, yAxis, inter, true);}
|
||||
void Init(Vector<double> &data, Vector<double> &xAxis, Vector<double> &yAxis,
|
||||
Interpolate inter) {TableData::Init(data, xAxis, yAxis, inter, true);}
|
||||
};
|
||||
|
||||
class TableDataPoints : public TableData {
|
||||
public:
|
||||
TableDataPoints() : TableData() {areas = false;}
|
||||
TableDataPoints(Vector<double> &data, Vector<double> &xAxis, Vector<double> &yAxis,
|
||||
Interpolate inter) {TableData::Init(data, xAxis, yAxis, inter, false);}
|
||||
void Init(Vector<double> &data, Vector<double> &xAxis, Vector<double> &yAxis,
|
||||
Interpolate inter) {TableData::Init(data, xAxis, yAxis, inter, false);}
|
||||
};
|
||||
|
||||
class ExplicitData : public DataSourceSurf {
|
||||
public:
|
||||
ExplicitData() {}
|
||||
ExplicitData(Function<double (double x, double y)> funz, double minX, double maxX, double minY, double maxY) {
|
||||
Init(funz, minX, maxX, minY, maxY);
|
||||
}
|
||||
void Init(Function<double (double x, double y)> funz, double minX, double maxX, double minY, double maxY);
|
||||
|
||||
double z(double x, double y) {return funz ? funz(x, y) : Null;}
|
||||
|
||||
bool IsEmpty() {return funz;}
|
||||
|
||||
double MinX() {return minX;}
|
||||
double MaxX() {return maxX;}
|
||||
double MinY() {return minY;}
|
||||
double MaxY() {return maxY;}
|
||||
double MinZ() {return minZ;}
|
||||
double MaxZ() {return maxZ;}
|
||||
|
||||
private:
|
||||
double minX, maxX, minY, maxY, minZ, maxZ;
|
||||
Function<double (double x, double y)> funz;
|
||||
};
|
||||
|
||||
Vector<Pointf> Intersection(Vector<Pointf> &poly1, Vector<Pointf> &poly2);
|
||||
void Simplify(Vector<Pointf> &poly, double dx, double dy);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
360
uppsrc/ScatterDraw/DrawingFunctions.cpp
Normal file
360
uppsrc/ScatterDraw/DrawingFunctions.cpp
Normal file
|
|
@ -0,0 +1,360 @@
|
|||
#include "ScatterDraw.h"
|
||||
|
||||
inline bool Even(int val) {return !(val%2);}
|
||||
|
||||
Vector <double> GetLineDash(String dash) {
|
||||
Vector<double> d;
|
||||
CParser p(dash);
|
||||
try {
|
||||
while(!p.IsEof())
|
||||
if(!p.Char(':')) {
|
||||
double data = p.ReadDouble();
|
||||
if (data > 0)
|
||||
d << data;
|
||||
}
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
|
||||
if(d.GetCount() & 1) {
|
||||
Vector<double> dash1;
|
||||
dash1.Append(d);
|
||||
dash1.Append(d);
|
||||
return dash1;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
Vector <double> &GetDashedArray(String dash) {
|
||||
static VectorMap <String, Vector <double> > pats;
|
||||
|
||||
int pos = pats.Find(dash);
|
||||
if (pos < 0) {
|
||||
pats.Add(dash, GetLineDash(dash));
|
||||
pos = pats.GetCount()-1;
|
||||
}
|
||||
return pats.GetValues()[pos];
|
||||
}
|
||||
|
||||
void ScatterDraw::ParseTextMultiline(const String &text, Upp::Font &fnt, Upp::Vector <String> &texts,
|
||||
Upp::Vector <Size> &sizes) {
|
||||
Size ret(0, 0);
|
||||
int npos = 0;
|
||||
for (int pos = 0; npos != -1; pos = npos+1) {
|
||||
npos = text.Find('\n', pos);
|
||||
String &t = texts.Add();
|
||||
if (npos != -1)
|
||||
t = text.Mid(pos, npos-pos);
|
||||
else
|
||||
t = text.Mid(pos);
|
||||
Size &s = sizes.Add();
|
||||
s.cx = GetTextSize(t, fnt).cx;
|
||||
s.cy = GetTextSize(t, fnt).cy;
|
||||
}
|
||||
}
|
||||
|
||||
Size GetTextSizeMultiline(Upp::Vector <Size> &sizes) {
|
||||
Size ret(0, 0);
|
||||
for (int i = 0; i < sizes.GetCount(); ++i) {
|
||||
if (sizes[i].cx > ret.cx)
|
||||
ret.cx = sizes[i].cx;
|
||||
ret.cy += sizes[i].cy;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DrawLine(Draw &w, double x0, double y0, double x1, double y1, double width, const Color &color) {
|
||||
w.DrawLine(int(x0), int(y0), int(x1), int(y1), int(width), color);
|
||||
}
|
||||
|
||||
void DrawLine(Painter &w, double x0, double y0, double x1, double y1, double width, const Color &color) {
|
||||
w.Move(x0, y0).Line(x0, y0).Line(x1, y1).Stroke(width, color);
|
||||
}
|
||||
|
||||
void DrawVArrow(Draw &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color) {
|
||||
DrawLine(w, x0, y0, x1, y1, width, color);
|
||||
if (fabs(y0 - y1) > 2*aHeight) {
|
||||
if (x0 > x1)
|
||||
Swap(x0, x1);
|
||||
if (y0 > y1)
|
||||
Swap(y0, y1);
|
||||
Vector <Point> arrowU, arrowL;
|
||||
arrowU << Point(int(x0), int(y0)) << Point(int(x0-aWidth), int(y0+aHeight)) << Point(int(x0+aWidth), int(y0+aHeight));
|
||||
w.DrawPolygon(arrowU, SColorHighlight());
|
||||
arrowL << Point(int(x0), int(y1)) << Point(int(x0-aWidth), int(y1-aHeight)) << Point(int(x0+aWidth), int(y1-aHeight));
|
||||
w.DrawPolygon(arrowL, SColorHighlight());
|
||||
}
|
||||
}
|
||||
|
||||
void DrawVArrow(Painter &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color) {
|
||||
DrawLine(w, x0, y0, x1, y1, width, color);
|
||||
if (fabs(y0 - y1) > 2*aHeight) {
|
||||
if (x0 > x1)
|
||||
Swap(x0, x1);
|
||||
if (y0 > y1)
|
||||
Swap(y0, y1);
|
||||
w.Move(x0, y0).Line(x0-aWidth, y0+aHeight).Line(x0+aWidth, y0+aHeight).Fill(SColorHighlight());
|
||||
w.Move(x0, y1).Line(x0-aWidth, y1-aHeight).Line(x0+aWidth, y1-aHeight).Fill(SColorHighlight());
|
||||
}
|
||||
}
|
||||
|
||||
void DrawHArrow(Draw &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color) {
|
||||
DrawLine(w, x0, y0, x1, y1, width, color);
|
||||
if (fabs(x0 - x1) > 2*aHeight) {
|
||||
if (x0 > x1)
|
||||
Swap(x0, x1);
|
||||
if (y0 > y1)
|
||||
Swap(y0, y1);
|
||||
Vector <Point> arrowL, arrowR;
|
||||
arrowL << Point(int(x0), int(y0)) << Point(int(x0+aHeight), int(y0+aWidth)) << Point(int(x0+aHeight), int(y0-aWidth));
|
||||
w.DrawPolygon(arrowL, SColorHighlight());
|
||||
arrowR << Point(int(x1), int(y0)) << Point(int(x1-aHeight), int(y0+aWidth)) << Point(int(x1-aHeight), int(y0-aWidth));
|
||||
w.DrawPolygon(arrowR, SColorHighlight());
|
||||
}
|
||||
}
|
||||
|
||||
void DrawHArrow(Painter &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color) {
|
||||
DrawLine(w, x0, y0, x1, y1, width, color);
|
||||
if (fabs(x0 - x1) > 2*aHeight) {
|
||||
if (x0 > x1)
|
||||
Swap(x0, x1);
|
||||
if (y0 > y1)
|
||||
Swap(y0, y1);
|
||||
w.Move(x0, y0).Line(x0+aHeight, y0+aWidth).Line(x0+aHeight, y0-aWidth).Fill(SColorHighlight());
|
||||
w.Move(x1, y0).Line(x1-aHeight, y0+aWidth).Line(x1-aHeight, y0-aWidth).Fill(SColorHighlight());
|
||||
}
|
||||
}
|
||||
|
||||
void DrawText(Draw &w, double x, double y, int angle, const String &text, Upp::Font font, Color color) {
|
||||
w.DrawText(int(x), int(y), angle, text, font, color);
|
||||
}
|
||||
|
||||
void DrawText(Painter &w, double x, double y, int angle, const String &text, Upp::Font font, Color color) {
|
||||
w.Begin();
|
||||
w.Translate(x, y).Rotate(-angle*M_PI/1800.);
|
||||
w.Text(0, 0, text, font).Fill(color);
|
||||
w.End();
|
||||
}
|
||||
|
||||
void Clip(Draw &w, double x, double y, double cx, double cy) {
|
||||
w.Clip(int(x), int(y), int(cx), int(cy));
|
||||
}
|
||||
|
||||
void Clip(Painter &w, double x, double y, double cx, double cy) {
|
||||
w.Rectangle(x, y, cx, cy).Clip();
|
||||
}
|
||||
|
||||
void ClipEnd(Draw &w) {
|
||||
w.End();
|
||||
}
|
||||
|
||||
void ClipEnd(Painter &w) {
|
||||
;
|
||||
}
|
||||
|
||||
void DrawLineOpa(Draw& w, double x0, double y0, double x1, double y1, double scale, double opacity,
|
||||
double thick, const Color &_color, String dash, const Color &background) {
|
||||
Vector<Pointf> p;
|
||||
p << Pointf(x0, y0) << Pointf(x1, y1);
|
||||
DrawPolylineOpa(w, p, scale, opacity, thick, _color, dash, background);
|
||||
}
|
||||
|
||||
void DrawCircleOpa(Draw& w, double x, double y, double r, double scale, double opacity,
|
||||
double thick, const Color &_color, String dash, const Color &background) {
|
||||
Vector<Pointf> p;
|
||||
for (double ang = 0; ang <= 2*M_PI; ang += 2*M_PI/50)
|
||||
p << Pointf(int(x + r*cos(ang)), int(y + r*sin(ang)));
|
||||
DrawPolylineOpa(w, p, scale, opacity, thick, _color, dash, background);
|
||||
}
|
||||
|
||||
void DashScaled(Painter& w, const String dash, double scale) {
|
||||
if (!dash.IsEmpty()) {
|
||||
Vector<double> d;
|
||||
double start = 0;
|
||||
CParser p(dash);
|
||||
try {
|
||||
while(!p.IsEof())
|
||||
if(p.Char(':'))
|
||||
start = p.ReadDouble();
|
||||
else
|
||||
d.Add(scale*p.ReadDouble());
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
w.Dash(d, scale*start);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawLineOpa(Painter& w, double x0, double y0, double x1, double y1, double scale,
|
||||
double opacity, double thick, const Color &color, String dash,
|
||||
const Color &background) {
|
||||
w.Move(Pointf(x0, y0));
|
||||
w.Line(Pointf(x1, y1));
|
||||
DashScaled(w, dash, scale);
|
||||
w.Opacity(opacity); // Before Stroke()
|
||||
w.Stroke(thick*scale, color);
|
||||
}
|
||||
|
||||
void DrawCircleOpa(Painter& w, double x, double y, double r, double scale,
|
||||
double opacity, double thick, const Color &color, String dash,
|
||||
const Color &background) {
|
||||
w.Circle(x, y, r);
|
||||
DashScaled(w, dash, scale);
|
||||
w.Opacity(opacity); // Before Stroke()
|
||||
w.Stroke(thick*scale, color);
|
||||
}
|
||||
|
||||
void FillRectangleOpa(Draw &w, double x0, double y0, double x1, double y1,
|
||||
double opacity, const Color &background, const Color &color) {
|
||||
if (IsNull(color))
|
||||
return;
|
||||
Color opacolor = GetOpaqueColor(color, background, opacity);
|
||||
if (x0 > x1)
|
||||
Swap(x0, x1);
|
||||
if (y0 > y1)
|
||||
Swap(y0, y1);
|
||||
w.DrawRect(int(x0), int(y0), abs(int(x1 - x0)), abs(int(y1 - y0)), opacolor);
|
||||
}
|
||||
|
||||
void FillRectangleOpa(Painter &w, double x0, double y0, double x1, double y1,
|
||||
double opacity, const Color &, const Color &color) {
|
||||
if (IsNull(color))
|
||||
return;
|
||||
w.Rectangle(x0, y0, x1 - x0, y1 - y0).Opacity(opacity).Fill(color);
|
||||
}
|
||||
|
||||
void FillRectangle(Draw &w, double x0, double y0, double x1, double y1, const Color &color) {
|
||||
if (IsNull(color))
|
||||
return;
|
||||
w.DrawRect(int(x0), int(y0), int(x1 - x0), int(y1 - y0), color);
|
||||
}
|
||||
|
||||
void FillRectangle(Painter &w, double x0, double y0, double x1, double y1, const Color &color) {
|
||||
if (IsNull(color))
|
||||
return;
|
||||
w.Rectangle(x0, y0, x1 - x0, y1 - y0).Fill(color);
|
||||
}
|
||||
|
||||
void DrawRectangle(Draw &w, double x0, double y0, double x1, double y1, double scale,
|
||||
double width, const Color &color) {
|
||||
int ix0 = int(x0);
|
||||
int iy0 = int(y0);
|
||||
int ix1 = int(x1);
|
||||
int iy1 = int(y1);
|
||||
int thick = int(width*scale);
|
||||
w.DrawLine(ix0, iy0, ix1, iy0, thick, color);
|
||||
w.DrawLine(ix1, iy0, ix1, iy1, thick, color);
|
||||
w.DrawLine(ix1, iy1, ix0, iy1, thick, color);
|
||||
w.DrawLine(ix0, iy1, ix0, iy0, thick, color);
|
||||
}
|
||||
|
||||
void DrawRectangle(Painter &w, double x0, double y0, double x1, double y1, double scale,
|
||||
double width, const Color &color) {
|
||||
w.Move(Pointf(x0, y0)).Line(Pointf(x1, y0)).Line(Pointf(x1, y1))
|
||||
.Line(Pointf(x0, y1)).Line(Pointf(x0, y0)).Stroke(width*scale, color);
|
||||
}
|
||||
|
||||
Pointf PointAtLen(const Pointf &p0, const Pointf &p1, double len) {
|
||||
Pointf ret;
|
||||
if (p1.y == p0.y) {
|
||||
ret.x = p0.x + ((p0.x < p1.x) ? len : -len);
|
||||
ret.y = p0.y;
|
||||
} else if (p1.x == p0.x) {
|
||||
ret.x = p0.x;
|
||||
ret.y = p0.y + ((p0.y < p1.y) ? len : -len);
|
||||
} else {
|
||||
double k = sqr((p1.x-p0.x)/(p1.y-p0.y));
|
||||
double deltax = len/sqrt(1/k + 1);
|
||||
double deltay = len/sqrt(k + 1);
|
||||
ret.x = p0.x + ((p0.x < p1.x) ? deltax : -deltax);
|
||||
ret.y = p0.y + ((p0.y < p1.y) ? deltay : -deltay);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DrawPolylineOpa(Draw& w, const Vector<Pointf> &p, double scale, double opacity,
|
||||
double thick, const Color &_color, String dash, const Color &background) {
|
||||
ASSERT(!p.IsEmpty());
|
||||
Color color = GetOpaqueColor(_color, background, opacity) ;
|
||||
if (dash == LINE_SOLID) {
|
||||
//w.DrawPolyline(p, int(thick*scale), color);
|
||||
for (int i = 1; i < p.GetCount(); ++i) {
|
||||
if (!(IsNull(p[i-1]) || IsNull(p[i])))
|
||||
w.DrawLine(p[i-1], p[i], int(thick*scale), color);
|
||||
}
|
||||
} else {
|
||||
Vector <double> &pat = GetDashedArray(dash);
|
||||
if (pat.IsEmpty())
|
||||
return;
|
||||
int iPat = 0;
|
||||
|
||||
double len = pat[0]*scale; // Pixels per bar
|
||||
Pointf begin, end;
|
||||
begin = p[0];
|
||||
for (int i = 1; i < p.GetCount();) {
|
||||
if (IsNull(begin) || IsNull(p[i]))
|
||||
i++;
|
||||
else {
|
||||
double d = Distance(begin, p[i]);
|
||||
if (d >= len)
|
||||
end = PointAtLen(begin, p[i], len);
|
||||
else {
|
||||
end = p[i];
|
||||
len -= d;
|
||||
++i;
|
||||
}
|
||||
if (Even(iPat))
|
||||
w.DrawLine(begin, end, int(thick*scale), color);
|
||||
if (d >= len) {
|
||||
iPat++;
|
||||
if (iPat == pat.GetCount())
|
||||
iPat = 0;
|
||||
len = pat[iPat]*scale;
|
||||
}
|
||||
begin = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawPolylineOpa(Painter& w, const Vector<Pointf> &p, double scale, double opacity,
|
||||
double thick, const Color &color, String dash, const Color &background) {
|
||||
ASSERT(!p.IsEmpty());
|
||||
bool broken = true;
|
||||
for (int i = 0; i < p.GetCount(); ++i) {
|
||||
if (IsNull(p[i]))
|
||||
broken = true;
|
||||
else {
|
||||
if (broken) {
|
||||
w.Move(p[i]);
|
||||
broken = false;
|
||||
} else
|
||||
w.Line(p[i]);
|
||||
}
|
||||
}
|
||||
DashScaled(w, dash, scale);
|
||||
w.Opacity(opacity); // Before Stroke()
|
||||
w.Stroke(thick*scale, color);
|
||||
}
|
||||
|
||||
void FillPolylineOpa(Draw& w, const Vector<Pointf> &p, double scale, double opacity,
|
||||
const Color &background, const Color &fillColor) {
|
||||
ASSERT(!p.IsEmpty());
|
||||
Color opacolor = GetOpaqueColor(fillColor, background, opacity) ;
|
||||
|
||||
Vector<Point> pi;
|
||||
pi.SetCount(p.GetCount());
|
||||
for (int i = 0; i < pi.GetCount(); ++i) {
|
||||
pi[i].x = (int)p[i].x;
|
||||
pi[i].y = (int)p[i].y;
|
||||
}
|
||||
w.DrawPolygon(pi, opacolor);
|
||||
}
|
||||
|
||||
void FillPolylineOpa(Painter& w, const Vector<Pointf> &p, double scale, double opacity,
|
||||
const Color &background, const Color &fillColor) {
|
||||
ASSERT(!p.IsEmpty());
|
||||
w.Move(p[0]);
|
||||
for (int i = 1; i < p.GetCount(); ++i)
|
||||
w.Line(p[i]);
|
||||
w.Opacity(opacity);
|
||||
w.Fill(fillColor); // Before Stroke()
|
||||
}
|
||||
|
|
@ -3,16 +3,30 @@
|
|||
|
||||
void DrawLine(Draw &w, double x0, double y0, double x1, double y1, double width, const Color &color);
|
||||
void DrawLine(Painter &w, double x0, double y0, double x1, double y1, double width, const Color &color);
|
||||
void DrawLineOpa(Draw& w, double x0, double y0, double x1, double y1, int scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void DrawLineOpa(Painter& w, double x0, double y0, double x1, double y1, int scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void DrawCircleOpa(Draw& w, double x, double y, double r, int scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void DrawCircleOpa(Painter& w, double x, double y, double r, int scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void FillRectangleOpa(Draw &w, double x0, double y0, double x1, double y1, int scale, double opacity, const Color &background, const Color &color);
|
||||
void FillRectangleOpa(Painter &w, double x0, double y0, double x1, double y1, int scale, double opacity, const Color &background, const Color &color);
|
||||
void DrawPolylineOpa(Draw& w, const Vector<Pointf> &p, int scale, double opacity, double thick, const Color &color, String pattern = "", const Color &background = Null);
|
||||
void DrawPolylineOpa(Painter& w, const Vector<Pointf> &p, int scale, double opacity, double thick, const Color &color, String pattern = "", const Color &background = Null);
|
||||
void FillPolylineOpa(Draw& w, const Vector<Pointf> &p, int scale, double opacity, const Color &background, const Color &fillColor);
|
||||
void FillPolylineOpa(Painter& w, const Vector<Pointf> &p, int scale, double opacity, const Color &background, const Color &fillColor);
|
||||
void DrawRectangle(Draw &w, double x0, double y0, double x1, double y1, double scale,
|
||||
double width, const Color &color);
|
||||
void DrawRectangle(Painter &w, double x0, double y0, double x1, double y1, double scale,
|
||||
double width, const Color &color);
|
||||
template <class T>
|
||||
void DrawRectangle(T &w, const Rectf &rect, double scale, double width, const Color &color) {
|
||||
DrawRectangle(w, rect.left, rect.top, rect.right, rect.bottom, scale, width, color);
|
||||
}
|
||||
void FillRectangle(Draw &w, double x0, double y0, double x1, double y1, const Color &color) ;
|
||||
void FillRectangle(Painter &w, double x0, double y0, double x1, double y1, const Color &color);
|
||||
template <class T>
|
||||
void FillRectangle(T &w, const Rectf &rect, const Color &color) {
|
||||
FillRectangle(w, rect.left, rect.top, rect.right, rect.bottom, color);
|
||||
}
|
||||
void DrawLineOpa(Draw& w, double x0, double y0, double x1, double y1, double scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void DrawLineOpa(Painter& w, double x0, double y0, double x1, double y1, double scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void DrawCircleOpa(Draw& w, double x, double y, double r, double scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void DrawCircleOpa(Painter& w, double x, double y, double r, double scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void FillRectangleOpa(Draw &w, double x0, double y0, double x1, double y1, double opacity, const Color &background, const Color &color);
|
||||
void FillRectangleOpa(Painter &w, double x0, double y0, double x1, double y1, double opacity, const Color &background, const Color &color);
|
||||
void DrawPolylineOpa(Draw& w, const Vector<Pointf> &p, double scale, double opacity, double thick, const Color &color, String pattern = "", const Color &background = Null);
|
||||
void DrawPolylineOpa(Painter& w, const Vector<Pointf> &p, double scale, double opacity, double thick, const Color &color, String pattern = "", const Color &background = Null);
|
||||
void FillPolylineOpa(Draw& w, const Vector<Pointf> &p, double scale, double opacity, const Color &background, const Color &fillColor);
|
||||
void FillPolylineOpa(Painter& w, const Vector<Pointf> &p, double scale, double opacity, const Color &background, const Color &fillColor);
|
||||
void DrawVArrow(Draw &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color);
|
||||
void DrawVArrow(Painter &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color);
|
||||
void DrawHArrow(Draw &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color);
|
||||
|
|
|
|||
|
|
@ -144,49 +144,161 @@ void EvalExpr::EvalThrowError(CParser &p, const char *s) {
|
|||
throw err;
|
||||
}
|
||||
|
||||
double safe_sqrt(double val) {
|
||||
if (val < 0)
|
||||
doubleUnit usqrt(doubleUnit val) {
|
||||
val.Sqrt();
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit ufabs(doubleUnit val) {
|
||||
val.val = fabs(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit uceil(doubleUnit val) {
|
||||
val.val = ceil(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit ufloor(doubleUnit val) {
|
||||
val.val = floor(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit usin(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
return sqrt(val);
|
||||
val.val = sin(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit ucos(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = cos(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit utan(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = tan(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit uasin(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = asin(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit uacos(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = acos(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit uatan(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = atan(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit usinh(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = sinh(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit ucosh(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = cosh(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit utanh(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = tanh(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit uexp(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = exp(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit uDegToRad(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = DegToRad(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit uRadToDeg(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = RadToDeg(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit ulog(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = log(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
doubleUnit ulog10(doubleUnit val) {
|
||||
if (!val.unit.IsAdim())
|
||||
return Null;
|
||||
val.val = log10(val.val);
|
||||
return val;
|
||||
}
|
||||
|
||||
EvalExpr::EvalExpr() {
|
||||
noCase = false;
|
||||
errorIfUndefined = false;
|
||||
|
||||
constants.Add("pi", M_PI);
|
||||
constants.Add("e", M_E);
|
||||
constants.Add("pi", doubleUnit(M_PI));
|
||||
constants.Add("e", doubleUnit(M_E));
|
||||
|
||||
functions.Add("abs", fabs);
|
||||
functions.Add("ceil", ceil);
|
||||
functions.Add("floor", floor);
|
||||
functions.Add("sqrt", safe_sqrt);
|
||||
functions.Add("sin", sin);
|
||||
functions.Add("cos", cos);
|
||||
functions.Add("tan", tan);
|
||||
functions.Add("asin", asin);
|
||||
functions.Add("acos", acos);
|
||||
functions.Add("atan", atan);
|
||||
functions.Add("sinh", sinh);
|
||||
functions.Add("cosh", cosh);
|
||||
functions.Add("tanh", tanh);
|
||||
functions.Add("log", log);
|
||||
functions.Add("log10", log10);
|
||||
functions.Add("exp", exp);
|
||||
functions.Add("degToRad", DegToRad);
|
||||
functions.Add("radToDeg", RadToDeg);
|
||||
functions.Add("abs", ufabs);
|
||||
functions.Add("ceil", uceil);
|
||||
functions.Add("floor", ufloor);
|
||||
functions.Add("sqrt", usqrt);
|
||||
functions.Add("sin", usin);
|
||||
functions.Add("cos", ucos);
|
||||
functions.Add("tan", utan);
|
||||
functions.Add("asin", uasin);
|
||||
functions.Add("acos", uacos);
|
||||
functions.Add("atan", uatan);
|
||||
functions.Add("sinh", usinh);
|
||||
functions.Add("cosh", ucosh);
|
||||
functions.Add("tanh", utanh);
|
||||
functions.Add("log", ulog);
|
||||
functions.Add("log10", ulog10);
|
||||
functions.Add("exp", uexp);
|
||||
functions.Add("degToRad", uDegToRad);
|
||||
functions.Add("radToDeg", uRadToDeg);
|
||||
}
|
||||
|
||||
double EvalExpr::Term(CParser& p) {
|
||||
doubleUnit EvalExpr::Term(CParser& p) {
|
||||
if(p.IsId()) {
|
||||
String strId = p.ReadId();
|
||||
if(double (*function)(double) = functions.Get(strId, 0)) {
|
||||
if(doubleUnit (*function)(doubleUnit) = functions.Get(strId, 0)) {
|
||||
p.PassChar('(');
|
||||
double x = Exp(p);
|
||||
doubleUnit x = Exp(p);
|
||||
p.PassChar(')');
|
||||
double ret = function(x);
|
||||
doubleUnit ret = function(x);
|
||||
if (IsNull(ret))
|
||||
EvalThrowError(p, Format(t_("Error in %s(%f)"), strId, x));
|
||||
EvalThrowError(p, Format(t_("Error in %s(%f)"), strId, x.val));
|
||||
return ret;
|
||||
}
|
||||
String strsearch;
|
||||
|
|
@ -194,7 +306,7 @@ double EvalExpr::Term(CParser& p) {
|
|||
strsearch = ToLower(strId);
|
||||
else
|
||||
strsearch = strId;
|
||||
double ret = constants.Get(strsearch, Null);
|
||||
doubleUnit ret = constants.Get(strsearch, Null);
|
||||
if (IsNull(ret)) {
|
||||
ret = variables.Get(strsearch, Null);
|
||||
if (IsNull(ret)) {
|
||||
|
|
@ -205,55 +317,65 @@ double EvalExpr::Term(CParser& p) {
|
|||
}
|
||||
return ret;
|
||||
} else if(p.Char('(')) {
|
||||
double x = Exp(p);
|
||||
doubleUnit x = Exp(p);
|
||||
p.PassChar(')');
|
||||
return x;
|
||||
} else
|
||||
return p.ReadDouble();
|
||||
return doubleUnit(p.ReadDouble());
|
||||
}
|
||||
|
||||
double EvalExpr::Pow(CParser& p) {
|
||||
double x = Term(p);
|
||||
doubleUnit EvalExpr::Pow(CParser& p) {
|
||||
doubleUnit x = Term(p);
|
||||
for(;;) {
|
||||
if(p.Char('^')) {
|
||||
if (x < 0)
|
||||
if (x.val < 0)
|
||||
EvalThrowError(p, t_("Complex number"));
|
||||
x = pow(x, Term(p));
|
||||
x.Exp(Term(p));
|
||||
} else
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
double EvalExpr::Mul(CParser& p) {
|
||||
double x = Pow(p);
|
||||
doubleUnit EvalExpr::Mul(CParser& p) {
|
||||
doubleUnit x = Pow(p);
|
||||
for(;;) {
|
||||
if(p.Char('*'))
|
||||
x = x * Mul(p);
|
||||
else if(p.Char('/')) {
|
||||
double y = Pow(p);
|
||||
if(y == 0)
|
||||
EvalThrowError(p, t_("Divide by zero"));
|
||||
x = x / y;
|
||||
x.Mult(Pow(p));
|
||||
else if(memcmp(p.GetPtr(), "·", strlen("·")) == 0) {
|
||||
CParser::Pos pos = p.GetPos();
|
||||
pos.ptr += strlen("·");
|
||||
p.SetPos(pos);
|
||||
p.Spaces();
|
||||
x.Mult(Pow(p));
|
||||
} else if(p.Char('/')) {
|
||||
x.Div(Pow(p));
|
||||
} else if(memcmp(p.GetPtr(), "º", strlen("º")) == 0) {
|
||||
CParser::Pos pos = p.GetPos();
|
||||
pos.ptr += strlen("º");
|
||||
p.SetPos(pos);
|
||||
p.Spaces();
|
||||
x.Mult(doubleUnit(M_PI/180.));
|
||||
} else
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
double EvalExpr::Exp(CParser& p) {
|
||||
double x = Mul(p);
|
||||
doubleUnit EvalExpr::Exp(CParser& p) {
|
||||
doubleUnit x = Mul(p);
|
||||
for(;;) {
|
||||
if(p.Char('+'))
|
||||
x = x + Mul(p);
|
||||
x.Sum(Mul(p));
|
||||
else if(p.Char('-'))
|
||||
x = x - Mul(p);
|
||||
else if(p.Char(':'))
|
||||
x = x*60 + Mul(p);
|
||||
else
|
||||
x.Sub(Mul(p));
|
||||
else if(p.Char(':')) {
|
||||
x.Mult(doubleUnit(60));
|
||||
x.Sum(Mul(p));
|
||||
} else
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
double EvalExpr::Eval(String line) {
|
||||
doubleUnit EvalExpr::Eval(String line) {
|
||||
line = TrimBoth(line);
|
||||
if (line.IsEmpty())
|
||||
return Null;
|
||||
|
|
@ -264,10 +386,10 @@ double EvalExpr::Eval(String line) {
|
|||
CParser::Pos pos = p.GetPos();
|
||||
String var = p.ReadId();
|
||||
if(p.Char('=')) {
|
||||
double ret = Exp(p);
|
||||
doubleUnit ret = Exp(p);
|
||||
if (noCase)
|
||||
var = ToLower(var);
|
||||
variables.GetAdd(var) = ret;
|
||||
SetVariable(var, ret);
|
||||
return ret;
|
||||
} else {
|
||||
p.SetPos(pos);
|
||||
|
|
@ -301,7 +423,7 @@ String EvalExpr::TermStr(CParser& p, int numDigits) {
|
|||
if (constants.Find(strId) >= 0)
|
||||
return strId;
|
||||
else {
|
||||
double dat = variables.GetAdd(strId, 0);
|
||||
double dat = variables.GetAdd(strId, 0).val;
|
||||
return FormatDoubleFix(dat, numDigits);
|
||||
}
|
||||
}
|
||||
|
|
@ -370,10 +492,15 @@ String EvalExpr::EvalStr(String line, int numDigits) {
|
|||
}
|
||||
} else
|
||||
return ExpStr(p, numDigits);
|
||||
}
|
||||
catch(CParser::Error e) {
|
||||
} catch(CParser::Error e) {
|
||||
lastError = Format(t_("Error evaluating '%s': %s"), line, e);
|
||||
return Null;
|
||||
} catch(String e) {
|
||||
lastError = Format(t_("Error: %s"), e);
|
||||
return Null;
|
||||
} catch(...) {
|
||||
lastError = t_("Unknown error");
|
||||
return Null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ public:
|
|||
virtual void GuessCoeff(DataSource &series) = 0;
|
||||
|
||||
virtual double f(double x1) = 0;
|
||||
virtual double f(double x1, double x2) {NEVER(); return Null;}
|
||||
virtual double f(Vector <double> x) {NEVER(); return Null;}
|
||||
virtual double f(double x1, double x2) {NEVER(); return Null;}
|
||||
virtual double f(Vector <double> x) {NEVER(); return Null;}
|
||||
virtual String GetName() = 0;
|
||||
virtual String GetFullName() {return GetName();}
|
||||
virtual String GetEquation(int numDigits = 3) = 0;
|
||||
|
|
@ -328,11 +328,117 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class Unit : public Moveable<Unit> {
|
||||
public:
|
||||
Unit() {SetNull();}
|
||||
Unit(const Nuller&) : Unit() {}
|
||||
Unit(double m, double l, double t) : m(m), l(l), t(t) {}
|
||||
String GetString() {
|
||||
if (IsNullInstance())
|
||||
return String();
|
||||
String ret;
|
||||
if (m != 0) {
|
||||
ret << "Kg";
|
||||
if (m != 1)
|
||||
ret << "^" << m;
|
||||
}
|
||||
if (l != 0) {
|
||||
if (!ret.IsEmpty())
|
||||
ret << "*";
|
||||
ret << "m";
|
||||
if (l != 1)
|
||||
ret << "^" << l;
|
||||
}
|
||||
if (t != 0) {
|
||||
if (!ret.IsEmpty())
|
||||
ret << "*";
|
||||
ret << "sec";
|
||||
if (t != 1)
|
||||
ret << "^" << t;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
bool IsEqual(const Unit &un) {return m == un.m && l == un.l && t == un.t;}
|
||||
void Mult(const Unit &un) {
|
||||
m += un.m;
|
||||
l += un.l;
|
||||
t += un.t;
|
||||
}
|
||||
void Div(const Unit &un) {
|
||||
m -= un.m;
|
||||
l -= un.l;
|
||||
t -= un.t;
|
||||
}
|
||||
void Exp(double exp) {
|
||||
m *= exp;
|
||||
l *= exp;
|
||||
t *= exp;
|
||||
}
|
||||
void Sqrt() {
|
||||
m /= 2.;
|
||||
l /= 2.;
|
||||
t /= 2.;
|
||||
}
|
||||
|
||||
void SetNull() {m = Null;}
|
||||
bool IsNullInstance() const {return Upp::IsNull(m);}
|
||||
bool IsAdim() const {return (m == 0) && (l == 0) && (t == 0);}
|
||||
|
||||
double m, l, t;
|
||||
};
|
||||
|
||||
class doubleUnit : public Moveable<doubleUnit> {
|
||||
public:
|
||||
doubleUnit() : doubleUnit(0) {}
|
||||
doubleUnit(double val) : val(val), unit(0, 0, 0) {}
|
||||
doubleUnit(const Nuller&) {SetNull();}
|
||||
|
||||
double val;
|
||||
Unit unit;
|
||||
|
||||
void Sum(const doubleUnit &d) {
|
||||
if (!(unit.IsEqual(d.unit) || IsNull(unit) || IsNull(d.unit)))
|
||||
throw(t_("Units does not match in summation"));
|
||||
val += d.val;
|
||||
}
|
||||
void Sub(const doubleUnit &d) {
|
||||
if (!(unit.IsEqual(d.unit) || IsNull(unit) || IsNull(d.unit)))
|
||||
throw(t_("Units does not match in substraction"));
|
||||
val -= d.val;
|
||||
}
|
||||
void Mult(const doubleUnit &d) {
|
||||
unit.Mult(d.unit);
|
||||
val *= d.val;
|
||||
}
|
||||
void Div(const doubleUnit &d) {
|
||||
unit.Div(d.unit);
|
||||
if (d.val < 1e-100)
|
||||
throw(t_("Division by zero"));
|
||||
val /= d.val;
|
||||
}
|
||||
void Exp(const doubleUnit &d) {
|
||||
if (!(IsNull(d.unit) || d.unit.IsAdim()))
|
||||
throw(t_("Exponent cannot have units"));
|
||||
unit.Mult(d.unit);
|
||||
val = pow(val, d.val);
|
||||
}
|
||||
void Sqrt() {
|
||||
if (val < 0)
|
||||
throw(t_("Negative number sqrt"));
|
||||
val = sqrt(val);
|
||||
unit.Sqrt();
|
||||
}
|
||||
void SetNull() {val = Null;}
|
||||
bool IsNullInstance() const {return IsNull(unit) && IsNull(val);}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class EvalExpr {
|
||||
public:
|
||||
EvalExpr();
|
||||
void Init() {variables.Clear();}
|
||||
double Eval(String line);
|
||||
doubleUnit Eval(String line);
|
||||
String EvalStr(String line, int numDigits = 3);
|
||||
EvalExpr &SetCaseSensitivity(bool val = true) {noCase = !val; return *this;}
|
||||
EvalExpr &SetErrorUndefined(bool val = true) {errorIfUndefined = val; return *this;}
|
||||
|
|
@ -340,33 +446,34 @@ public:
|
|||
const String &GetFunction(int id) {return functions.GetKey(id);}
|
||||
int GetFunctionsCount() {return functions.GetCount();}
|
||||
|
||||
void SetConstant(String name, double value = 0) {constants.GetAdd(name) = value;}
|
||||
void SetConstant(int id, double value = 0) {constants[id] = value;}
|
||||
double GetConstant(String name) {return constants.Get(name, Null);}
|
||||
void GetConstant(int id, String &name, double &value) {name = constants.GetKey(id); value = constants[id];}
|
||||
void SetConstant(String name, doubleUnit value) {constants.GetAdd(name) = value;}
|
||||
void SetConstant(int id, doubleUnit value) {constants[id] = value;}
|
||||
const doubleUnit &GetConstant(String name) {return constants.Get(name, Null);}
|
||||
void GetConstant(int id, String &name, doubleUnit &val) {name = constants.GetKey(id); val = constants[id];}
|
||||
int GetConstantId(String &name) {return constants.Find(name);}
|
||||
int GetConstantsCount() {return constants.GetCount();}
|
||||
|
||||
void SetVariable(String name, double value = 0) {variables.GetAdd(name) = value;}
|
||||
void SetVariable(int id, double value = 0) {variables[id] = value;}
|
||||
double GetVariable(String name) {return variables.GetAdd(name);}
|
||||
void GetVariable(int id, String &name, double &value) {name = variables.GetKey(id); value = variables[id];}
|
||||
void SetVariable(String name, doubleUnit value) {variables.GetAdd(name) = value;}
|
||||
void SetVariable(int id, doubleUnit value) {variables[id] = value;}
|
||||
doubleUnit GetVariable(String name) {return variables.GetAdd(name);}
|
||||
void GetVariable(int id, String &name, doubleUnit &val) {name = variables.GetKey(id); val = variables[id];}
|
||||
int GetVariablesCount() {return variables.GetCount();}
|
||||
void ClearVariables();
|
||||
String &GetLastError() {return lastError;}
|
||||
|
||||
VectorMap<String, double> constants;
|
||||
VectorMap<String, double (*)(double)> functions;
|
||||
VectorMap<String, doubleUnit> constants;
|
||||
VectorMap<String, doubleUnit (*)(doubleUnit)> functions;
|
||||
|
||||
CParser p;
|
||||
|
||||
static void EvalThrowError(CParser &p, const char *s);
|
||||
|
||||
protected:
|
||||
double Exp(CParser& p);
|
||||
doubleUnit Exp(CParser& p);
|
||||
|
||||
bool noCase;
|
||||
String lastError;
|
||||
VectorMap<String, double> variables;
|
||||
VectorMap<String, doubleUnit> variables;
|
||||
bool errorIfUndefined;
|
||||
|
||||
bool IsFunction(String str) {return functions.Get(str, 0);}
|
||||
|
|
@ -374,9 +481,9 @@ protected:
|
|||
|
||||
private:
|
||||
void *Functions_Get(CParser& p);
|
||||
double Term(CParser& p);
|
||||
double Pow(CParser& p);
|
||||
double Mul(CParser& p);
|
||||
doubleUnit Term(CParser& p);
|
||||
doubleUnit Pow(CParser& p);
|
||||
doubleUnit Mul(CParser& p);
|
||||
|
||||
String TermStr(CParser& p, int numDigits);
|
||||
String PowStr(CParser& p, int numDigits);
|
||||
|
|
@ -397,14 +504,14 @@ public:
|
|||
return;
|
||||
strEquation = parts[0];
|
||||
eval.Init();
|
||||
eval.SetConstant(varHoriz);
|
||||
eval.SetConstant(varHoriz, doubleUnit(23));
|
||||
idx = eval.GetConstantsCount() - 1;
|
||||
eval.EvalStr(strEquation);
|
||||
coeff.Clear();
|
||||
varNames.Clear();
|
||||
for (int i = 0; i < eval.GetVariablesCount(); ++i) {
|
||||
String varName;
|
||||
double dummy;
|
||||
doubleUnit dummy;
|
||||
eval.GetVariable(i, varName, dummy);
|
||||
varNames << varName;
|
||||
int istr;
|
||||
|
|
@ -422,18 +529,16 @@ public:
|
|||
}
|
||||
}
|
||||
double f(double x) {
|
||||
eval.SetConstant(idx, x);
|
||||
for (int i = 0; i < coeff.GetCount(); ++i) {
|
||||
eval.SetConstant(idx, doubleUnit(x));
|
||||
for (int i = 0; i < coeff.GetCount(); ++i)
|
||||
eval.SetVariable(varNames[i], coeff[i]);
|
||||
double ret = eval.GetVariable(varNames[i]);
|
||||
}
|
||||
return eval.Eval(strEquation);
|
||||
return eval.Eval(strEquation).val;
|
||||
}
|
||||
void SetName(String _name) {name = _name;}
|
||||
virtual String GetName() {return name;}
|
||||
virtual String GetEquation(int numDigits = 3) {return eval.EvalStr(strEquation, numDigits);}
|
||||
virtual void GuessCoeff(DataSource &series) {}
|
||||
void SetDegree(int num) {NEVER();}
|
||||
virtual void GuessCoeff(DataSource & ) {}
|
||||
void SetDegree(int ) {NEVER();}
|
||||
|
||||
private:
|
||||
String name;
|
||||
|
|
|
|||
220
uppsrc/ScatterDraw/Legend.cpp
Normal file
220
uppsrc/ScatterDraw/Legend.cpp
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
#include "ScatterDraw.h"
|
||||
|
||||
int ScatterDraw::NumSeriesLegend() const {
|
||||
int num = 0;
|
||||
for (int i = 0; i < series.GetCount(); ++i) {
|
||||
if (series[i].showLegend)
|
||||
num++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
void ScatterDraw::DrawLegend(Draw& w) const {
|
||||
if (series.IsEmpty())
|
||||
return;
|
||||
int nlab = NumSeriesLegend();
|
||||
if (nlab == 0)
|
||||
return;
|
||||
|
||||
Upp::Font scaledFont = legendFont;
|
||||
double textScale = min(plotScaleX, plotScaleY);
|
||||
int rowHeight = int(textScale*scaledFont.GetHeight());
|
||||
int rowAscent = int(textScale*scaledFont.GetAscent());
|
||||
scaledFont.Height(rowHeight);
|
||||
int xWidth = scaledFont.GetWidth('X');
|
||||
int lineLen = 4*xWidth;
|
||||
|
||||
Vector<String> legends;
|
||||
int legendWidth = 0;
|
||||
for (int i = 0; i < series.GetCount(); ++i) {
|
||||
if (series[i].showLegend) {
|
||||
String legend = series[i].legend;
|
||||
if (!series[i].unitsY.IsEmpty())
|
||||
legend += " [" + series[i].unitsY + "]";
|
||||
legends.Add(legend);
|
||||
legendWidth = max<int>(legendWidth, GetTextSize(legend, scaledFont).cx);
|
||||
}
|
||||
}
|
||||
legendWidth += lineLen + 4*xWidth;
|
||||
|
||||
int rowIncSign;
|
||||
int plotW, plotH;
|
||||
int nlr;
|
||||
int topClip;
|
||||
int plotLeft, plotTop, rectWidth, rectHeight;
|
||||
int loclegendRowSpacing;
|
||||
if (legendAnchor == TOP) {
|
||||
plotLeft = plotTop = 0;
|
||||
plotW = size.cx - int((hPlotLeft + hPlotRight)*plotScaleX);
|
||||
plotH = int(plotScaleY*(vPlotTop - 1) + titleHeight);
|
||||
rowIncSign = -1;
|
||||
rectWidth = plotW;
|
||||
rectHeight = plotH;
|
||||
topClip = 0;
|
||||
nlr = fround(rectWidth/legendWidth);
|
||||
loclegendRowSpacing = 0;
|
||||
} else {
|
||||
plotW = size.cx - int(hPlotLeft*plotScaleX);
|
||||
plotH = size.cy - int((vPlotTop + vPlotBottom)*plotScaleY - titleHeight);
|
||||
rowIncSign = 1;
|
||||
if (IsNull(legendPos))
|
||||
return;
|
||||
|
||||
plotLeft = int(plotScaleX*hPlotLeft);
|
||||
plotTop = int(plotScaleY*vPlotTop + titleHeight);
|
||||
rectWidth = legendWidth*legendNumCols;
|
||||
topClip = int(plotScaleY*vPlotTop + titleHeight);
|
||||
nlr = legendNumCols;
|
||||
loclegendRowSpacing = int(legendRowSpacing*textScale);
|
||||
}
|
||||
if (nlr <= 0)
|
||||
return;
|
||||
|
||||
int nrows = fceil(double(nlab)/nlr);
|
||||
|
||||
if (legendAnchor != TOP)
|
||||
rectHeight = int(rowHeight*(nrows + 0.2)) + loclegendRowSpacing*nrows;
|
||||
|
||||
double left = plotLeft + legendPos.x*textScale;
|
||||
double right = plotW + (hPlotLeft - hPlotRight)*plotScaleX - legendPos.x*textScale - rectWidth;
|
||||
double top = plotTop + legendPos.y*textScale;
|
||||
double bottom = plotH - legendPos.y*textScale - rectHeight;
|
||||
Rectf rect;
|
||||
switch(legendAnchor) {
|
||||
case TOP: rect.Set(plotScaleX*hPlotLeft, 0, rectWidth, rectHeight); break;
|
||||
case LEFT_TOP: rect.Set(left, top, left + rectWidth, top + rectHeight); break;
|
||||
case RIGHT_TOP: rect.Set(right, top, right + rectWidth, top + rectHeight); break;
|
||||
case LEFT_BOTTOM: rect.Set(left, bottom, left + rectWidth, bottom + rectHeight); break;
|
||||
case RIGHT_BOTTOM: rect.Set(right, bottom, right + rectWidth, bottom + rectHeight);break;
|
||||
}
|
||||
|
||||
w.Clip(int(plotScaleX*hPlotLeft), topClip, plotW, plotH);
|
||||
|
||||
if (legendAnchor != TOP) {
|
||||
if (!IsNull(legendFillColor))
|
||||
FillRectangle(w, rect, legendFillColor);
|
||||
if (!IsNull(legendBorderColor))
|
||||
DrawRectangle(w, rect, textScale, 1, legendBorderColor);
|
||||
}
|
||||
Upp::Font italic = scaledFont;
|
||||
italic.Italic();
|
||||
scaledFont.Bold();
|
||||
for(int row = 0, start = 0, i = 0, ireal = 0; row <= nrows; row++) {
|
||||
for(; ireal < min(start + nlr, nlab); i++) {
|
||||
if (series[i].showLegend) {
|
||||
double lx = rect.left + (ireal - start)*legendWidth + xWidth;
|
||||
double ly = (rowIncSign >= 0 ? rect.top : rect.bottom) +
|
||||
rowIncSign*int(rowHeight*(row + 0.6) + loclegendRowSpacing*(row + 0.5));
|
||||
Vector <Pointf> line;
|
||||
line << Pointf(lx, ly) << Pointf(lx + lineLen, ly);
|
||||
if (series[i].opacity > 0 && series[i].seriesPlot)
|
||||
DrawPolylineOpa(w, line, plotScaleAvg, 1, series[i].thickness, series[i].color, series[i].dash);
|
||||
Pointf mark_p(lx + xWidth, ly);
|
||||
if (series[i].markWidth >= 1 && series[i].markPlot)
|
||||
series[i].markPlot->Paint(w, plotScaleAvg, mark_p, series[i].markWidth, series[i].markColor,
|
||||
series[i].markBorderWidth, series[i].markBorderColor);
|
||||
Upp::Font &font = series[i].primaryY ? scaledFont : italic;
|
||||
DrawText(w, lx + lineLen + xWidth, ly - int((2*rowAscent)/3), 0, legends[ireal], font, series[i].color);
|
||||
ireal++;
|
||||
}
|
||||
}
|
||||
start = ireal;
|
||||
}
|
||||
w.End();
|
||||
}
|
||||
|
||||
void ScatterDraw::DrawRainbowPalette(Draw& w) const {
|
||||
double plotLeft = plotScaleX*hPlotLeft;
|
||||
double plotTop = plotScaleY*vPlotTop + titleHeight;
|
||||
double plotRight = size.cx - hPlotRight*plotScaleX;
|
||||
double plotBottom = size.cy - vPlotBottom*plotScaleY;
|
||||
|
||||
double rainbowPosx = rainbowPos.x*plotScaleX;
|
||||
double rainbowPosy = rainbowPos.y*plotScaleY;
|
||||
double rainbowSizecx = rainbowSize.cx*plotScaleX;
|
||||
double rainbowSizecy = rainbowSize.cy*plotScaleY;
|
||||
|
||||
Rect rect;
|
||||
Font fnt = rainbowPaletteFont;
|
||||
fnt.Height(int(fnt.GetHeight()*min(plotScaleX, plotScaleY)));
|
||||
switch(rainbowAnchor) {
|
||||
case LEFT_TOP: rect.Set(int(plotLeft + rainbowPosx),
|
||||
int(plotTop + rainbowPosy),
|
||||
int(plotLeft + rainbowPosx + rainbowSizecx),
|
||||
int(plotTop + rainbowPosy + rainbowSizecy));
|
||||
break;
|
||||
case RIGHT_TOP: rect.Set(int(plotRight - rainbowPosx - rainbowSizecx),
|
||||
int(plotTop + rainbowPosy),
|
||||
int(plotRight - rainbowPosx),
|
||||
int(plotTop + rainbowPosy + rainbowSizecy));
|
||||
break;
|
||||
case LEFT_BOTTOM: rect.Set(int(plotLeft + rainbowPosx),
|
||||
int(plotBottom- rainbowPosy - rainbowSizecy),
|
||||
int(plotLeft + rainbowPosx + rainbowSizecx),
|
||||
int(plotBottom- rainbowPosy));
|
||||
break;
|
||||
case RIGHT_BOTTOM: rect.Set(int(plotRight - rainbowPosx - rainbowSizecx),
|
||||
int(plotBottom- rainbowPosy - rainbowSizecy),
|
||||
int(plotRight - rainbowPosx),
|
||||
int(plotBottom- rainbowPosy));
|
||||
break;
|
||||
}
|
||||
|
||||
if (!surfUnits.IsEmpty()) {
|
||||
Size unitsSize = GetTextSize(surfUnits, fnt);
|
||||
switch (surfUnitsPos) {
|
||||
case UNITS_TOP: w.DrawText(int(rect.left + rect.GetWidth()/2. - unitsSize.cx/2.),
|
||||
int(rect.top - unitsSize.cy*1.3),
|
||||
surfUnits, fnt, rainbowPaletteTextColor);
|
||||
break;
|
||||
case UNITS_BOTTOM: w.DrawText(int(rect.left + rect.GetWidth()/2. - unitsSize.cx/2.),
|
||||
int(rect.bottom + unitsSize.cy*0.3),
|
||||
surfUnits, fnt, rainbowPaletteTextColor);
|
||||
break;
|
||||
case UNITS_LEFT: w.DrawText(int(rect.left - 1.3*unitsSize.cy),
|
||||
int(rect.top + rect.GetHeight()/2. - unitsSize.cx/2.), 900,
|
||||
surfUnits, fnt, rainbowPaletteTextColor);
|
||||
break;
|
||||
case UNITS_RIGHT: w.DrawText(int(rect.right + 0.3*unitsSize.cy),
|
||||
int(rect.top + rect.GetHeight()/2. - unitsSize.cx/2.), 900,
|
||||
surfUnits, fnt, rainbowPaletteTextColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double textX = 0;
|
||||
switch (surfLegendPos) {
|
||||
case LEGEND_RIGHT: textX = rect.right + 4*plotScaleX;
|
||||
break;
|
||||
case LEGEND_LEFT: textX = rect.left - 4*plotScaleX;
|
||||
break;
|
||||
}
|
||||
|
||||
ImageBuffer out_image(rect.GetWidth(), rect.GetHeight());
|
||||
|
||||
double delta = rect.GetHeight();
|
||||
for (int iy = 0; iy < delta; ++iy) {
|
||||
Color col = GetRainbowColor((delta - iy)/delta, surfRainbow,
|
||||
continuousColor ? 0 : surfNumColor);
|
||||
for (int ix = 0; ix < rect.GetWidth(); ++ix)
|
||||
out_image[iy][ix] = col;
|
||||
}
|
||||
w.DrawImage(rect.left, rect.top, out_image);
|
||||
DrawRectangle(w, rect, plotScaleAvg, 1, rainbowBorderColor);
|
||||
|
||||
double deltaZ = (surfMaxZ - surfMinZ)/double(surfNumColor);
|
||||
for (int i = 0; i <= surfNumColor; ++i) {
|
||||
double val = surfMinZ + deltaZ*i;
|
||||
String txt = VariableFormatZ(val);
|
||||
Size textSize = GetTextSize(txt, fnt);
|
||||
double deltax = 0;
|
||||
if (surfLegendPos == LEGEND_LEFT)
|
||||
deltax = textSize.cx;
|
||||
double deltay = textSize.cy/2;
|
||||
double ypos = rect.bottom - (i*rect.GetHeight())/double(surfNumColor);
|
||||
w.DrawText(int(textX - deltax), int(ypos - deltay), txt, fnt, rainbowPaletteTextColor);
|
||||
if (i > 0 && i < surfNumColor)
|
||||
DrawLine(w, rect.left, ypos, rect.right, ypos, 1*plotScaleAvg, rainbowBorderColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5,16 +5,16 @@ class MarkPlot {
|
|||
public:
|
||||
MarkPlot() : multiPlot(false), type(0) {}
|
||||
virtual ~MarkPlot() {};
|
||||
virtual void Paint(Draw &p, const int& scale, const Point& cp, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const {};
|
||||
virtual void Paint(Draw &p, const int& scale, int x, int y, const Vector<int>& dataX,
|
||||
virtual void Paint(Draw &p, const double& scale, const Point& cp, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const = 0;
|
||||
virtual void Paint(Draw &p, const double& scale, int x, int y, const Vector<int>& dataX,
|
||||
const Vector<int>& dataY, const Vector<double>& dataFixed, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const {};
|
||||
virtual void Paint(Painter &p, const int& scale, const Point& cp, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const {};
|
||||
virtual void Paint(Painter &p, const int& scale, int x, int y, const Vector<int>& dataX,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const {NEVER();};
|
||||
virtual void Paint(Painter &p, const double& scale, const Point& cp, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const = 0;
|
||||
virtual void Paint(Painter &p, const double& scale, int x, int y, const Vector<int>& dataX,
|
||||
const Vector<int>& dataY, const Vector<double>& dataFixed, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const {};
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const {NEVER();};
|
||||
template<class T>
|
||||
static void Register(const String& name)
|
||||
{
|
||||
|
|
@ -47,7 +47,7 @@ public:
|
|||
virtual int GetTypeCount() {return 0;}
|
||||
virtual const char **TypeString() {return NULL;}
|
||||
|
||||
//void SetTypeType(int _type) {type = _type;}
|
||||
void SetTypeType(int type) {this->type = type;}
|
||||
int GetTypeType() {return type;}
|
||||
|
||||
protected:
|
||||
|
|
@ -67,7 +67,7 @@ protected:
|
|||
class CircleMarkPlot : public MarkPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void DoPaint(T& w, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
int radius = fround(scale*size);
|
||||
|
|
@ -76,12 +76,12 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
void Paint(Draw &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Draw &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor, markBorderWidth, markBorderColor);
|
||||
}
|
||||
void Paint(Painter &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Painter &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor, markBorderWidth, markBorderColor);
|
||||
|
|
@ -91,7 +91,7 @@ public:
|
|||
class SquareMarkPlot : public MarkPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void DoPaint(T& w, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
Vector <Point> p;
|
||||
|
|
@ -104,12 +104,12 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
void Paint(Draw &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Draw &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor, markBorderWidth, markBorderColor);
|
||||
}
|
||||
void Paint(Painter &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Painter &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor, markBorderWidth, markBorderColor);
|
||||
|
|
@ -119,7 +119,7 @@ public:
|
|||
class TriangleMarkPlot : public MarkPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void DoPaint(T& w, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
Vector <Point> p;
|
||||
|
|
@ -133,12 +133,12 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
void Paint(Draw &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Draw &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor, markBorderWidth, markBorderColor);
|
||||
}
|
||||
void Paint(Painter &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Painter &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor, markBorderWidth, markBorderColor);
|
||||
|
|
@ -148,21 +148,21 @@ public:
|
|||
class CrossMarkPlot : public MarkPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, const int& scale, const Point& cp, const double& size, const Color& markColor) const
|
||||
void DoPaint(T& w, const double& scale, const Point& cp, const double& size, const Color& markColor) const
|
||||
{
|
||||
int side2l = int((size*scale)/2.);
|
||||
int side2r = int(size*scale - side2l);
|
||||
w.DrawLine(cp.x - side2l, cp.y, cp.x + side2r, cp.y, scale, markColor);
|
||||
w.DrawLine(cp.x, cp.y - side2l, cp.x, cp.y + side2r, scale, markColor);
|
||||
w.DrawLine(cp.x - side2l, cp.y, cp.x + side2r, cp.y, fround(scale), markColor);
|
||||
w.DrawLine(cp.x, cp.y - side2l, cp.x, cp.y + side2r, fround(scale), markColor);
|
||||
}
|
||||
|
||||
public:
|
||||
void Paint(Draw &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Draw &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor);
|
||||
}
|
||||
void Paint(Painter &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Painter &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor);
|
||||
|
|
@ -172,21 +172,21 @@ public:
|
|||
class XMarkPlot : public MarkPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, const int& scale, const Point& cp, const double& size, const Color& markColor) const
|
||||
void DoPaint(T& w, const double& scale, const Point& cp, const double& size, const Color& markColor) const
|
||||
{
|
||||
int side2l = int((size*scale)/2.);
|
||||
int side2r = int(size*scale - side2l);
|
||||
w.DrawLine(cp.x - side2l, cp.y - side2l, cp.x + side2r, cp.y + side2r, scale, markColor);
|
||||
w.DrawLine(cp.x + side2r, cp.y - side2l, cp.x - side2l, cp.y + side2r, scale, markColor);
|
||||
w.DrawLine(cp.x - side2l, cp.y - side2l, cp.x + side2r, cp.y + side2r, fround(scale), markColor);
|
||||
w.DrawLine(cp.x + side2r, cp.y - side2l, cp.x - side2l, cp.y + side2r, fround(scale), markColor);
|
||||
}
|
||||
|
||||
public:
|
||||
void Paint(Draw &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Draw &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor);
|
||||
}
|
||||
void Paint(Painter &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Painter &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor);
|
||||
|
|
@ -196,7 +196,7 @@ public:
|
|||
class RhombMarkPlot : public MarkPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, const int& scale, const Point& cp, const double& size, const Color& markColor) const
|
||||
void DoPaint(T& w, const double& scale, const Point& cp, const double& size, const Color& markColor) const
|
||||
{
|
||||
Vector <Point> p;
|
||||
int side2l = int((size*scale)/2.);
|
||||
|
|
@ -204,16 +204,16 @@ private:
|
|||
p << Point(cp.x, cp.y - side2l) << Point(cp.x + side2r, cp.y)
|
||||
<< Point(cp.x, cp.y + side2r) << Point(cp.x - side2l, cp.y)
|
||||
<< Point(cp.x, cp.y - side2l);
|
||||
w.DrawPolygon(p, markColor, scale/2, markColor);
|
||||
w.DrawPolygon(p, markColor, fround(scale/2.), markColor);
|
||||
}
|
||||
|
||||
public:
|
||||
void Paint(Draw &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Draw &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor);
|
||||
}
|
||||
void Paint(Painter &p, const int& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
void Paint(Painter &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, cp, size, markColor);
|
||||
|
|
@ -237,7 +237,7 @@ public:
|
|||
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, const int& scale, int x, int y, const Vector<int>& dataX,
|
||||
void DoPaint(T& w, const double& scale, int x, int y, const Vector<int>& dataX,
|
||||
const Vector<int>& dataY, const double& size, const Color& markColor) const
|
||||
{
|
||||
int side2l = int((size*scale)/2.);
|
||||
|
|
@ -266,70 +266,83 @@ private:
|
|||
if (!dataY.IsEmpty()) {
|
||||
if (type == ALL) {
|
||||
for (int i = 0; i < dataY.GetCount(); ++i)
|
||||
w.DrawLine(x - side2l, dataY[i], x + side2r, dataY[i], scale, markColor);
|
||||
w.DrawLine(x - side2l, dataY[i], x + side2r, dataY[i], fround(scale), markColor);
|
||||
} else {
|
||||
w.DrawLine(x - side2l, min, x + side2r, min, scale, markColor);
|
||||
w.DrawLine(x - side2l, max, x + side2r, max, scale, markColor);
|
||||
w.DrawLine(x - side2l, min, x + side2r, min, fround(scale), markColor);
|
||||
w.DrawLine(x - side2l, max, x + side2r, max, fround(scale), markColor);
|
||||
if (type == MIN_AVG_MAX)
|
||||
w.DrawLine(x - side2l, avg, x + side2r, avg, scale*4, markColor);
|
||||
w.DrawLine(x - side2l, avg, x + side2r, avg, fround(scale*4), markColor);
|
||||
}
|
||||
w.DrawLine(x, min, x, max, scale, markColor);
|
||||
w.DrawLine(x, min, x, max, fround(scale), markColor);
|
||||
} else {
|
||||
if (type == ALL) {
|
||||
for (int i = 0; i < dataX.GetCount(); ++i)
|
||||
w.DrawLine(dataX[i], y - side2l, dataX[i], y + side2r, scale, markColor);
|
||||
w.DrawLine(dataX[i], y - side2l, dataX[i], y + side2r, fround(scale), markColor);
|
||||
} else {
|
||||
w.DrawLine(min, y - side2l, min, y + side2r, scale, markColor);
|
||||
w.DrawLine(max, y - side2l, max, y + side2r, scale, markColor);
|
||||
w.DrawLine(min, y - side2l, min, y + side2r, fround(scale), markColor);
|
||||
w.DrawLine(max, y - side2l, max, y + side2r, fround(scale), markColor);
|
||||
if (type == MIN_AVG_MAX)
|
||||
w.DrawLine(avg, y - side2l, avg, y + side2r, scale*4, markColor);
|
||||
w.DrawLine(avg, y - side2l, avg, y + side2r, fround(scale*4), markColor);
|
||||
}
|
||||
w.DrawLine(min, y, max, y, scale, markColor);
|
||||
w.DrawLine(min, y, max, y, fround(scale), markColor);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void Paint(Draw &p, const int& scale, int x, int y, const Vector<int>& dataX,
|
||||
virtual void Paint(Draw &p, const double& scale, int x, int y, const Vector<int>& dataX,
|
||||
const Vector<int>& dataY, const Vector<double>& dataFixed, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, x, y, dataX, dataY, size, markColor);
|
||||
}
|
||||
virtual void Paint(Painter &p, const int& scale, int x, int y, const Vector<int>& dataX,
|
||||
virtual void Paint(Painter &p, const double& scale, int x, int y, const Vector<int>& dataX,
|
||||
const Vector<int>& dataY, const Vector<double>& dataFixed, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, x, y, dataX, dataY, size, markColor);
|
||||
}
|
||||
void Paint(Draw &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{}
|
||||
void Paint(Painter &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{}
|
||||
};
|
||||
|
||||
class BubblePlot : public MarkPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, const int& scale, int x, int y, const Vector<double>& dataFixed, const double& size,
|
||||
void DoPaint(T& w, const double& scale, int x, int y, const Vector<double>& dataFixed, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
int diameter = int(dataFixed[0]);
|
||||
int radius = int(dataFixed[0]/2);
|
||||
if (dataFixed.IsEmpty())
|
||||
return;
|
||||
int diameter = int(scale*dataFixed[0]);
|
||||
int radius = int(scale*dataFixed[0]/2.);
|
||||
w.DrawEllipse(x - radius, y - radius, diameter, diameter, markColor, fround(markBorderWidth), markBorderColor);
|
||||
}
|
||||
|
||||
public:
|
||||
BubblePlot() {multiPlot = true;}
|
||||
virtual void Paint(Draw &p, const int& scale, int x, int y, const Vector<int>& dataX,
|
||||
virtual void Paint(Draw &p, const double& scale, int x, int y, const Vector<int>& dataX,
|
||||
const Vector<int>& dataY, const Vector<double>& dataFixed, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, x, y, dataFixed, size, markColor, markBorderWidth, markBorderColor);
|
||||
}
|
||||
virtual void Paint(Painter &p, const int& scale, int x, int y, const Vector<int>& dataX,
|
||||
virtual void Paint(Painter &p, const double& scale, int x, int y, const Vector<int>& dataX,
|
||||
const Vector<int>& dataY, const Vector<double>& dataFixed, const double& size,
|
||||
const Color& markColor, const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{
|
||||
DoPaint(p, scale, x, y, dataFixed, size, markColor, markBorderWidth, markBorderColor);
|
||||
}
|
||||
void Paint(Draw &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{}
|
||||
void Paint(Painter &p, const double& scale, const Point& cp, const double& size, const Color& markColor,
|
||||
const double& markBorderWidth, const Color& markBorderColor) const
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -36,18 +36,24 @@ esES("N\303\272mero complejo")
|
|||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Divide by zero")
|
||||
caES("")
|
||||
esES("Divisi\303\263n entre cero")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Error evaluating '%s': %s")
|
||||
caES("")
|
||||
esES("Error evaluando '%s': %s")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Error: %s")
|
||||
caES("")
|
||||
esES("")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Unknown error")
|
||||
caES("")
|
||||
esES("")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
|
||||
// Equation.h
|
||||
|
||||
|
|
@ -116,3 +122,42 @@ caES("")
|
|||
esES("")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Units does not match in summation")
|
||||
caES("")
|
||||
esES("")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Units does not match in substraction")
|
||||
caES("")
|
||||
esES("")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Division by zero")
|
||||
caES("")
|
||||
esES("")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Exponent cannot have units")
|
||||
caES("")
|
||||
esES("")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Negative number sqrt")
|
||||
caES("")
|
||||
esES("")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
|
||||
// Obsolete
|
||||
|
||||
T_("Divide by zero")
|
||||
caES("")
|
||||
esES("Divisi\303\263n entre cero")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
|
|
|||
|
|
@ -13,9 +13,12 @@ file
|
|||
DataSource.h,
|
||||
Equation.cpp,
|
||||
Equation.h,
|
||||
DrawingFunctions.cpp,
|
||||
DrawingFunctions.h,
|
||||
SeriesPlot.h,
|
||||
MarkPlot.h,
|
||||
Legend.cpp,
|
||||
Surf.cpp,
|
||||
PieDraw.cpp,
|
||||
PieDraw.h,
|
||||
ScatterDraw.t,
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
class SeriesPlot {
|
||||
public:
|
||||
virtual ~SeriesPlot() {};
|
||||
virtual void Paint(Draw& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
virtual void Paint(Draw& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, double fx, double fy, int y0, double width,
|
||||
bool isClosed) const {};
|
||||
virtual void Paint(Painter& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
const Color &fillColor, double fx, double fy, double y0, double width,
|
||||
bool isClosed) const = 0;
|
||||
virtual void Paint(Painter& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, double fx, double fy, int y0, double width,
|
||||
bool isClosed) const {};
|
||||
const Color &fillColor, double fx, double fy, double y0, double width,
|
||||
bool isClosed) const = 0;
|
||||
template<class T>
|
||||
static void Register(const String& name)
|
||||
{
|
||||
|
|
@ -44,9 +44,9 @@ protected:
|
|||
class LineSeriesPlot : public SeriesPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
void DoPaint(T& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, int y0, bool isClosed) const
|
||||
const Color &fillColor, double y0, bool isClosed) const
|
||||
{
|
||||
if (!IsNull(fillColor)) {
|
||||
if(isClosed)
|
||||
|
|
@ -65,17 +65,17 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
void Paint(Draw& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
void Paint(Draw& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, double fx, double fy, int y0, double width, bool isClosed) const
|
||||
const Color &fillColor, double fx, double fy, double y0, double width, bool isClosed) const
|
||||
{
|
||||
DoPaint(w, p, scale, opacity, fround(thick), color, pattern, background, fillColor, y0, isClosed);
|
||||
DoPaint(w, p, scale, opacity, thick, color, pattern, background, fillColor, y0, isClosed);
|
||||
}
|
||||
void Paint(Painter& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
void Paint(Painter& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, double fx, double fy, int y0, double width, bool isClosed) const
|
||||
const Color &fillColor, double fx, double fy, double y0, double width, bool isClosed) const
|
||||
{
|
||||
DoPaint(w, p, scale, opacity, fround(thick), color, pattern, background, fillColor, y0, isClosed);
|
||||
DoPaint(w, p, scale, opacity, thick, color, pattern, background, fillColor, y0, isClosed);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -83,9 +83,9 @@ public:
|
|||
class StaggeredSeriesPlot : public SeriesPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
void DoPaint(T& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, int y0) const
|
||||
const Color &fillColor, double y0) const
|
||||
{
|
||||
ASSERT(p.GetCount() > 1);
|
||||
Vector<Pointf> ps;
|
||||
|
|
@ -109,15 +109,15 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
void Paint(Draw& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
void Paint(Draw& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, double fx, double fy, int y0, double width, bool isClosed) const
|
||||
const Color &fillColor, double fx, double fy, double y0, double width, bool isClosed) const
|
||||
{
|
||||
DoPaint(w, p, scale, opacity, thick, color, pattern, background, fillColor, y0);
|
||||
}
|
||||
void Paint(Painter& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
void Paint(Painter& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, double fx, double fy, int y0, double width, bool isClosed) const
|
||||
const Color &fillColor, double fx, double fy, double y0, double width, bool isClosed) const
|
||||
{
|
||||
DoPaint(w, p, scale, opacity, thick, color, pattern, background, fillColor, y0);
|
||||
}
|
||||
|
|
@ -126,12 +126,12 @@ public:
|
|||
class BarSeriesPlot : public SeriesPlot {
|
||||
private:
|
||||
template <class T>
|
||||
void DoPaint(T& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
void DoPaint(T& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, double fx, int y0, double width) const
|
||||
const Color &fillColor, double fx, double y0, double width) const
|
||||
{
|
||||
for (int i = 0; i < p.GetCount(); ++i) {
|
||||
FillRectangleOpa(w, p[i].x - width*fx, y0, p[i].x + width*fx, p[i].y, scale, opacity, background, fillColor);
|
||||
FillRectangleOpa(w, p[i].x - width*fx, y0, p[i].x + width*fx, p[i].y, opacity, background, fillColor);
|
||||
Vector<Pointf> ps;
|
||||
ps << Pointf(fround(p[i].x - width*fx), y0) << Pointf(fround(p[i].x - width*fx), p[i].y)
|
||||
<< Pointf(fround(p[i].x + width*fx), p[i].y) << Pointf(fround(p[i].x + width*fx), y0);
|
||||
|
|
@ -140,15 +140,15 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
void Paint(Draw& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
void Paint(Draw& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, double fx, double fy, int y0, double width, bool isClosed) const
|
||||
const Color &fillColor, double fx, double fy, double y0, double width, bool isClosed) const
|
||||
{
|
||||
DoPaint(w, p, scale, opacity, thick, color, pattern, background, fillColor, fx, y0, width);
|
||||
}
|
||||
void Paint(Painter& w, Vector<Pointf> &p, const int &scale, const double opacity,
|
||||
void Paint(Painter& w, Vector<Pointf> &p, const double &scale, const double opacity,
|
||||
double thick, const Color &color, String pattern, const Color &background,
|
||||
const Color &fillColor, double fx, double fy, int y0, double width, bool isClosed) const
|
||||
const Color &fillColor, double fx, double fy, double y0, double width, bool isClosed) const
|
||||
{
|
||||
DoPaint(w, p, scale, opacity, thick, color, pattern, background, fillColor, fx, y0, width);
|
||||
}
|
||||
|
|
|
|||
67
uppsrc/ScatterDraw/Surf.cpp
Normal file
67
uppsrc/ScatterDraw/Surf.cpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#include "ScatterDraw.h"
|
||||
|
||||
|
||||
ScatterDraw& ScatterDraw::AddSurf(DataSourceSurf &surf) {
|
||||
this->surf = &surf;
|
||||
if (IsNull(surfMinZ))
|
||||
surfMinZ = surf.MinZ();
|
||||
if (IsNull(surfMaxZ))
|
||||
surfMaxZ = surf.MaxZ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline static double Smooth01(double val) {
|
||||
double val2 = val*val;
|
||||
return 3*val2 - 2*val2*val;
|
||||
}
|
||||
|
||||
inline static double Smooth01Left(double val) {return 2*Smooth01(val/2);}
|
||||
inline static double Smooth01Right(double val) {return 2*(Smooth01(0.5 + val/2)-0.5);}
|
||||
|
||||
inline static double Filter01(double frac) {
|
||||
if (frac >= 1)
|
||||
return 1;
|
||||
else if (frac < 0)
|
||||
return 0;
|
||||
return frac;
|
||||
}
|
||||
|
||||
static Color InterpolateColor(double frac, const Color &from, const Color &to) {
|
||||
return Color(int(from.GetR() + frac*(to.GetR() - from.GetR())),
|
||||
int(from.GetG() + frac*(to.GetG() - from.GetG())),
|
||||
int(from.GetB() + frac*(to.GetB() - from.GetB())));
|
||||
}
|
||||
|
||||
Color GetRainbowColor(double frac, RAINBOW rainbow, int numScales) {
|
||||
frac = Filter01(frac);
|
||||
switch (rainbow) {
|
||||
case BLUE_YELLOW_RED: frac = 1 - frac;
|
||||
case RED_YELLOW_BLUE: return GetRainbowColor(frac, Color(255,0,0), Color(255,255,0), Color(0,0,255), numScales);
|
||||
case GREEN_YELLOW_RED: frac = 1 - frac;
|
||||
case RED_YELLOW_GREEN: return GetRainbowColor(frac, Color(255,0,0), Color(255,255,0), Color(0,255,0), numScales);
|
||||
case WHITE_BLACK: frac = 1 - frac;
|
||||
case BLACK_WHITE: return GetRainbowColor(frac, Color(0,0,0), Color(255,255,255), numScales);
|
||||
case BLUE_WHITE_RED: frac = 1 - frac;
|
||||
case RED_WHITE_BLUE: return GetRainbowColor(frac, Color(255,0,0), Color(255,255,255), Color(0,0,255), numScales);
|
||||
}
|
||||
return Null;
|
||||
}
|
||||
|
||||
Color GetRainbowColor(double frac, const Color &from, const Color &to, int numScales) {
|
||||
if (numScales > 0)
|
||||
frac = (int(frac*numScales)/double(numScales))/(1 - 1/numScales);
|
||||
frac = Filter01(frac);
|
||||
return InterpolateColor(frac, from, to);
|
||||
}
|
||||
|
||||
Color GetRainbowColor(double frac, const Color &col0, const Color &col1, const Color &col2, int numScales) {
|
||||
if (IsNull(col2))
|
||||
return GetRainbowColor(frac, col0, col1, numScales);
|
||||
if (numScales > 0)
|
||||
frac = int(frac*numScales)/double(numScales - 1);
|
||||
frac = Filter01(frac);
|
||||
if (frac < 0.5)
|
||||
return InterpolateColor((numScales > 0) ? 2*frac : Smooth01Right(2*frac), col0, col1);
|
||||
else
|
||||
return InterpolateColor((numScales > 0) ? 2*(frac - 0.5) : Smooth01Left(2*(frac - 0.5)), col1, col2);
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
topic "1 ScatterDraw";
|
||||
[ $$0,0#00000000000000000000000000000000:Default]
|
||||
[0 $$1,0#96390100711032703541132217272105:end]
|
||||
[i448;a25;kKO9;2 $$2,0#37138531426314131252341829483380:class]
|
||||
[l288;2 $$3,0#27521748481378242620020725143825:desc]
|
||||
|
|
@ -7,6 +6,7 @@ topic "1 ScatterDraw";
|
|||
[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item]
|
||||
[H6;0 $$6,0#05600065144404261032431302351956:begin]
|
||||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[ $$0,0#00000000000000000000000000000000:Default]
|
||||
[{_}%EN-US
|
||||
[ {{10000@3 [s0; [*@(229)4 ScatterDraw]]}}&]
|
||||
[s1; &]
|
||||
|
|
@ -46,43 +46,42 @@ there is an overview of control possibilities.]&]
|
|||
[@(0.0.255) int], [@(0.0.255) double]>_[* cbModifFormatX]&]
|
||||
[s3; If set this callback will give the String to be painted beside
|
||||
every X axis grid line and in the pop window. The input values
|
||||
are the X axis value set as int and double.&]
|
||||
are the X axis value index and value.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:cbModifFormatDeltaX:%- [_^Callback3^ Callback3]<String[@(0.0.255) `&],
|
||||
[@(0.0.255) int], [@(0.0.255) double]>_[* cbModifFormatDeltaX]&]
|
||||
[s3; If set this callback will give the String to be painted in the
|
||||
pop window representing the delta between two X axis points.
|
||||
The input values are the X axis value set as int and double.&]
|
||||
The input values are the X axis value index and value.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:cbModifFormatY:%- [_^Callback3^ Callback3]<String[@(0.0.255) `&],
|
||||
[@(0.0.255) int], [@(0.0.255) double]>_[* cbModifFormatY]&]
|
||||
[s3; If set this callback will give the String to be painted beside
|
||||
every main Y axis grid line and in the pop window. The input
|
||||
values are the Y axis value set as int and double.&]
|
||||
values are the Y axis value index and value.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:cbModifFormatDeltaY:%- [_^Callback3^ Callback3]<String[@(0.0.255) `&],
|
||||
[@(0.0.255) int], [@(0.0.255) double]>_[* cbModifFormatDeltaY]&]
|
||||
[s3; If set this callback will give the String to be painted in the
|
||||
pop window representing the delta between two Y axis points.
|
||||
The input values are the Y axis value set as int and double.&]
|
||||
The input values are the Y axis value index and value.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:cbModifFormatY2:%- [_^Callback3^ Callback3]<String[@(0.0.255) `&],
|
||||
[@(0.0.255) int], [@(0.0.255) double]>_[* cbModifFormatY2]&]
|
||||
[s3; If set this callback will give the String to be painted beside
|
||||
every secondary and in the pop window Y axis grid line. The input
|
||||
values are the Y axis value set as int and double.&]
|
||||
values are the Y axis value index and value.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:cbModifFormatDeltaY2:%- [_^Callback3^ Callback3]<String[@(0.0.255) `&
|
||||
], [@(0.0.255) int], [@(0.0.255) double]>_[* cbModifFormatDeltaY2]&]
|
||||
[s3; If set this callback will give the String to be painted in the
|
||||
pop window representing the secondary delta between two Y axis
|
||||
points. The input values are the Y axis value set as int and
|
||||
double.&]
|
||||
points. The input values are the Y axis value index and value.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:WhenZoomScroll:%- [_^Callback^ Callback]_[* WhenZoomScroll]&]
|
||||
|
|
@ -97,8 +96,24 @@ double.&]
|
|||
[s3; Callback called when scatter plot origin is changed.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetSize`(Size`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&]_[* SetSi
|
||||
ze]([_^Size^ Size]_[*@3 sz])&]
|
||||
[s5;:ScatterDraw`:`:WhenPainter:%- [_^Upp`:`:Callback1^ Callback1]<Painter[@(0.0.255) `&]>
|
||||
_[* WhenPainter]&]
|
||||
[s3; Callback called before control Paint with Painter to draw additional
|
||||
graphics.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:WhenDraw:%- [_^Upp`:`:Callback1^ Callback1]<Draw[@(0.0.255) `&]>_[* Whe
|
||||
nDraw]&]
|
||||
[s3; Callback called before control Paint with Draw to draw additional
|
||||
graphics&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:WhenZoomToFit:%- [_^Upp`:`:Callback^ Callback]_[* WhenZoomToFit]&]
|
||||
[s3; Callback called after ZoomToFit() function.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetSize`(const Upp`:`:Size`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetSize]([_^Size^ Size]_[*@3 sz])&]
|
||||
[s3; Sets the control size with [%-*@3 sz]. Functions like GetImage()
|
||||
will return a bitmap of [%-*@3 sz] size.&]
|
||||
[s1; &]
|
||||
|
|
@ -109,12 +124,12 @@ onst]&]
|
|||
a bitmap of [%-*@3 sz] size.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetColor`(const Color`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
[s5;:ScatterDraw`:`:SetColor`(const Upp`:`:Color`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 color])&]
|
||||
[s3; Sets [%-*@3 color] .as graph background color.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetTitle`(const String`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
[s5;:ScatterDraw`:`:SetTitle`(const Upp`:`:String`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetTitle]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 title])&]
|
||||
[s3; Sets [%-*@3 title] as graph title.&]
|
||||
[s1; &]
|
||||
|
|
@ -124,21 +139,27 @@ etTitle]()&]
|
|||
[s3; Returns graph title.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetTitleFont`(const Font`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
[s5;:ScatterDraw`:`:SetTitleFont`(const Upp`:`:Font`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetTitleFont]([@(0.0.255) const]_[_^Font^ Font][@(0.0.255) `&]_[*@3 fontTitle])&]
|
||||
[s3; Sets [%-*@3 fontTitle] as title font.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetTitleColor`(const Color`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetTitleColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 colorTitle])&]
|
||||
[s5;:ScatterDraw`:`:SetTitleColor`(const Upp`:`:Color`&`):%- [_^ScatterDraw^ ScatterDra
|
||||
w][@(0.0.255) `&]_[* SetTitleColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 c
|
||||
olorTitle])&]
|
||||
[s3; Sets [%-*@3 colorTitle] as title text color.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetTitleColor`(`):%- [_^Upp`:`:Color^ Upp`::Color][@(0.0.255) `&]_[* Get
|
||||
TitleColor]()&]
|
||||
[s3; Returns the title color.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetTitleFont`(`):%- [_^Font^ Font][@(0.0.255) `&]_[* GetTitleFont]()&]
|
||||
[s3; Returns the title font.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetLabels`(const String`&`,const String`&`,const String`&`):%- [@(0.0.255) v
|
||||
[s5;:ScatterDraw`:`:SetLabels`(const Upp`:`:String`&`,const Upp`:`:String`&`,const Upp`:`:String`&`):%- [@(0.0.255) v
|
||||
oid]_[* SetLabels]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 xLabel],
|
||||
[@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 yLabel], [@(0.0.255) const]_[_^String^ S
|
||||
tring][@(0.0.255) `&]_[*@3 yLabel2]_`=_`"`")&]
|
||||
|
|
@ -146,7 +167,7 @@ tring][@(0.0.255) `&]_[*@3 yLabel2]_`=_`"`")&]
|
|||
axis ([%-*@3 yLabel]) and secondary vertical axis ([%-*@3 yLabel2]).&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetLabelX`(const String`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
[s5;:ScatterDraw`:`:SetLabelX`(const Upp`:`:String`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetLabelX]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 xLabel])&]
|
||||
[s3; Sets [%-*@3 xLabel] as the label of the horizontal axis.&]
|
||||
[s1; &]
|
||||
|
|
@ -156,7 +177,7 @@ axis ([%-*@3 yLabel]) and secondary vertical axis ([%-*@3 yLabel2]).&]
|
|||
[s3; Returns the label of the horizontal axis.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetLabelY`(const String`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
[s5;:ScatterDraw`:`:SetLabelY`(const Upp`:`:String`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetLabelY]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 yLabel])&]
|
||||
[s3; Sets [%-*@3 yLabel] as the label of the vertical axis.&]
|
||||
[s1; &]
|
||||
|
|
@ -166,7 +187,7 @@ axis ([%-*@3 yLabel]) and secondary vertical axis ([%-*@3 yLabel2]).&]
|
|||
[s3; Returns the label of the vertical axis.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetLabelY2`(const String`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
[s5;:ScatterDraw`:`:SetLabelY2`(const Upp`:`:String`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetLabelY2]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 yLabel])&]
|
||||
[s3; Sets [%-*@3 yLabel] as the label of the secondary vertical axis.&]
|
||||
[s1; &]
|
||||
|
|
@ -176,8 +197,9 @@ axis ([%-*@3 yLabel]) and secondary vertical axis ([%-*@3 yLabel2]).&]
|
|||
[s3; Returns the label of the secondary vertical axis.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetLabelsFont`(const Font`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetLabelsFont]([@(0.0.255) const]_[_^Font^ Font][@(0.0.255) `&]_[*@3 fontLabels])&]
|
||||
[s5;:ScatterDraw`:`:SetLabelsFont`(const Upp`:`:Font`&`):%- [_^ScatterDraw^ ScatterDraw
|
||||
][@(0.0.255) `&]_[* SetLabelsFont]([@(0.0.255) const]_[_^Font^ Font][@(0.0.255) `&]_[*@3 font
|
||||
Labels])&]
|
||||
[s3; Sets [%-*@3 fontLabels] as the labels font.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
|
|
@ -185,8 +207,9 @@ axis ([%-*@3 yLabel]) and secondary vertical axis ([%-*@3 yLabel2]).&]
|
|||
[s3; Returns the font of the labels.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetLabelsColor`(const Color`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetLabelsColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 colorLabels])&]
|
||||
[s5;:ScatterDraw`:`:SetLabelsColor`(const Upp`:`:Color`&`):%- [_^ScatterDraw^ ScatterDr
|
||||
aw][@(0.0.255) `&]_[* SetLabelsColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 c
|
||||
olorLabels])&]
|
||||
[s3; Sets [%-*@3 colorLabels] as the color of the labels.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
|
|
@ -242,9 +265,9 @@ argin]()&]
|
|||
[s3; Returns the plot area bottom margin.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetPlotAreaColor`(const Color`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetPlotAreaColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 p`_a`_color])
|
||||
&]
|
||||
[s5;:ScatterDraw`:`:SetPlotAreaColor`(const Upp`:`:Color`&`):%- [_^ScatterDraw^ Scatter
|
||||
Draw][@(0.0.255) `&]_[* SetPlotAreaColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&
|
||||
]_[*@3 p`_a`_color])&]
|
||||
[s3; Sets [%-*@3 p`_a`_color] as the plot area background color.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
|
|
@ -253,8 +276,9 @@ olor]()&]
|
|||
[s3; Returns the plot area background color.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetAxisColor`(const Color`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetAxisColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 axis`_color])&]
|
||||
[s5;:ScatterDraw`:`:SetAxisColor`(const Upp`:`:Color`&`):%- [_^ScatterDraw^ ScatterDraw
|
||||
][@(0.0.255) `&]_[* SetAxisColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 axi
|
||||
s`_color])&]
|
||||
[s3; Sets [%-*@3 axis`_color] as the color of the axis.&]
|
||||
[s0; -|
|
||||
@@image:756&406
|
||||
|
|
@ -267,8 +291,9 @@ etAxisWidth]([@(0.0.255) int]_[*@3 axis`_width])&]
|
|||
[s3; Sets [%-*@3 axis`_width] as the width of the axis in pixels.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetGridColor`(const Color`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetGridColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 grid`_color])&]
|
||||
[s5;:ScatterDraw`:`:SetGridColor`(const Upp`:`:Color`&`):%- [_^ScatterDraw^ ScatterDraw
|
||||
][@(0.0.255) `&]_[* SetGridColor]([@(0.0.255) const]_[_^Color^ Color][@(0.0.255) `&]_[*@3 gri
|
||||
d`_color])&]
|
||||
[s3; Sets [%-*@3 grid`_color] as the color of the grid.&]
|
||||
[s0; -|
|
||||
@@image:737&400
|
||||
|
|
@ -308,8 +333,8 @@ are described legend details.&]
|
|||
are described legend details.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetLegendPos`(const Point`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetLegendPos]([@(0.0.255) const]_[_^Point^ Point]_`&[*@3 pos])&]
|
||||
[s5;:ScatterDraw`:`:SetLegendPos`(const Upp`:`:Point`&`):%- [_^ScatterDraw^ ScatterDraw
|
||||
][@(0.0.255) `&]_[* SetLegendPos]([@(0.0.255) const]_[_^Point^ Point]_`&[*@3 pos])&]
|
||||
[s3; Sets the coordinates ([%-*@3 pos]) of the legend table corner
|
||||
relative to the plot corner.&]
|
||||
[s3; [^topic`:`/`/ScatterDraw`/srcdoc`/LegendTable`$en`-us^ Here ]there
|
||||
|
|
@ -414,8 +439,8 @@ END`_ANCHOR`_RIGHT`_BOTTOM]&]
|
|||
&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetLegendAnchor`(int`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&]_
|
||||
[* SetLegendAnchor]([@(0.0.255) int]_[*@3 anchor])&]
|
||||
[s5;:ScatterDraw`:`:SetLegendAnchor`(LEGEND`_POS`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetLegendAnchor]([@(0.0.255) LEGEND`_POS]_[*@3 anchor])&]
|
||||
[s3; Sets with [%-*@3 anchor ]the legend table position:&]
|
||||
[s3;i150;O0; LEGEND`_TOP,&]
|
||||
[s3;i150;O0; LEGEND`_ANCHOR`_LEFT`_TOP, &]
|
||||
|
|
@ -429,12 +454,14 @@ END`_ANCHOR`_RIGHT`_BOTTOM]&]
|
|||
&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetLegendAnchor`(`):%- [@(0.0.255) int]_[* GetLegendAnchor]()&]
|
||||
[s5;:ScatterDraw`:`:GetLegendAnchor`(`):%- [@(0.0.255) LEGEND`_POS]_[* GetLegendAnchor]()
|
||||
&]
|
||||
[s3; Returns the legend table position.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetLegendFillColor`(const Color`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetLegendFillColor]([@(0.0.255) const]_[_^Color^ Color]_`&[*@3 color])&]
|
||||
[s5;:ScatterDraw`:`:SetLegendFillColor`(const Upp`:`:Color`&`):%- [_^ScatterDraw^ Scatt
|
||||
erDraw][@(0.0.255) `&]_[* SetLegendFillColor]([@(0.0.255) const]_[_^Color^ Color]_`&[*@3 co
|
||||
lor])&]
|
||||
[s3; Sets with [%-*@3 color] the legend background color.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
|
|
@ -469,6 +496,14 @@ e]([@(0.0.255) int]_[*@3 `_mode]_`=_MD`_ANTIALIASED)&]
|
|||
[s3; Returns the drawing mode as documented in SetMode().&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:ZoomToFit`(bool`,bool`,double`):%- [@(0.0.255) void]_[* ZoomToFit]([@(0.0.255) b
|
||||
ool]_[*@3 horizontal], [@(0.0.255) bool]_[*@3 vertical]_`=_[@(0.0.255) false],
|
||||
[@(0.0.255) double]_[*@3 factor]_`=_[@3 0])&]
|
||||
[s3; Rescales the x axis if [%-*@3 horizontal ]is true and y axis if
|
||||
[%-*@3 vertical] is true to show all graphs data.on the control.
|
||||
[%-*@3 factor] indicates the fit factor (0 fills the control) .&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:Zoom`(double`,bool`,bool`):%- [@(0.0.255) void]_[* Zoom]([@(0.0.255) do
|
||||
uble]_[*@3 scale], [@(0.0.255) bool]_[*@3 hor]_`=_[@(0.0.255) true],
|
||||
[@(0.0.255) bool]_[*@3 ver]_`=_[@(0.0.255) true])&]
|
||||
|
|
@ -494,6 +529,74 @@ other control.&]
|
|||
&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:Unlinked`(`):%- [@(0.0.255) void]_[* Unlinked]()&]
|
||||
[s3; Unlinks series.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:AddSurf`(Upp`:`:DataSourceSurf`&`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* AddSurf]([_^Upp`:`:DataSourceSurf^ DataSourceSurf]_`&[*@3 surf])&]
|
||||
[s3; Adds the 2D surface [%-*@3 surf].&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetSurfMinZ`(double`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&]_
|
||||
[* SetSurfMinZ]([@(0.0.255) double]_[*@3 val])&]
|
||||
[s3; Sets [%-*@3 val] as the minimum 2D surface Z value.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetSurfMinZ`(`)const:%- [@(0.0.255) double]_[* GetSurfMinZ]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s3; Returns the minimum 2D surface Z value.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetSurfMaxZ`(double`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&]_
|
||||
[* SetSurfMaxZ]([@(0.0.255) double]_[*@3 val])&]
|
||||
[s3; Sets [%-*@3 val] as the maximum 2D surface Z value.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetSurfMaxZ`(`)const:%- [@(0.0.255) double]_[* GetSurfMaxZ]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s3; Returns the maximum 2D surface Z value.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:ZoomToFitZ`(`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&]_[* ZoomTo
|
||||
FitZ]()&]
|
||||
[s3; Calculates the minimum and maximum 2D surface Z values and sets
|
||||
them as minimum ans maximum values to be plotted.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:ShowRainbowPalette`(bool`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* ShowRainbowPalette]([@(0.0.255) bool]_[*@3 show]_`=_[@(0.0.255) true])&]
|
||||
[s3; If [%-*@3 show] is true 2D surface rainbow color palette will
|
||||
be shown.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetShowRainbowPalette`(`):%- [@(0.0.255) bool]_[* GetShowRainbowPalet
|
||||
te]()&]
|
||||
[s3; Returns true if 2D surface rainbow color palette is shown.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetRainbowPalettePos`(const Upp`:`:Point`&`):%- [_^ScatterDraw^ Sca
|
||||
tterDraw][@(0.0.255) `&]_[* SetRainbowPalettePos]([@(0.0.255) const]_[_^Upp`:`:Point^ Poi
|
||||
nt]_`&[*@3 p])&]
|
||||
[s3; Sets [%-*@3 p] as the position of 2D surface rainbow color palette.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetRainbowPalettePos`(`):%- [_^Upp`:`:Point^ Point][@(0.0.255) `&]_[* G
|
||||
etRainbowPalettePos]()&]
|
||||
[s3; Returns the 2D surface rainbow color palette position.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetRainbowPaletteSize`(const Upp`:`:Size`&`):%- [_^ScatterDraw^ Sca
|
||||
tterDraw][@(0.0.255) `&]_[* SetRainbowPaletteSize]([@(0.0.255) const]_[_^Upp`:`:Size^ Siz
|
||||
e]_`&[*@3 sz])&]
|
||||
[s3; Sets [%-*@3 sz] as the Size of 2D surface rainbow color palette.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetRainbowPaletteSize`(`):%- [_^Upp`:`:Size^ Size][@(0.0.255) `&]_[* Ge
|
||||
tRainbowPaletteSize]()&]
|
||||
[s3; Returns the 2D surface rainbow color palette size.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetZoomStyleX`(ZoomStyle`):%- [_^ScatterDraw^ ScatterDraw]_`&[* SetZo
|
||||
omStyleX](ZoomStyle_[*@3 style]_`=_TO`_CENTER)&]
|
||||
[s3; Sets the X zoom [%-*@3 style]. Valid values are:&]
|
||||
|
|
@ -551,11 +654,11 @@ MaxMajorUnits]([@(0.0.255) int]_[*@3 maxX], [@(0.0.255) int]_[*@3 maxY])&]
|
|||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetMajorUnitsX`(`):%- [@(0.0.255) double]_[* GetMajorUnitsX]()&]
|
||||
[s3; Returns the maximum number of horizontal grid lines.&]
|
||||
[s3; Returns the distance between grid lines in X axis.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetMajorUnitsY`(`):%- [@(0.0.255) double]_[* GetMajorUnitsY]()&]
|
||||
[s3; Returns the maximum number of vertical grid lines.&]
|
||||
[s3; Returns the distance between grid lines in Y axis.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetMinUnits`(double`,double`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
|
|
@ -585,15 +688,7 @@ le]_[*@3 ymin2]_`=_[@3 0])&]
|
|||
[s3; Sets with [%-*@3 xmin], [%-*@3 ymin] and [%-*@3 ymin2] the X, Y and
|
||||
secondary Y axis origin.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:Upp`:`:ScatterDraw`:`:ZoomToFit`(bool`,bool`,double`):%- [@(0.0.255) void]_[* ZoomTo
|
||||
Fit]([@(0.0.255) bool]_[*@3 horizontal]_`=_[@(0.0.255) true], [@(0.0.255) bool]_[*@3 vertic
|
||||
al]_`=_[@(0.0.255) false], [@(0.0.255) double]_[*@3 factor]_`=_[@3 0])&]
|
||||
[s3; Rescales the x axis if [%-*@3 horizontal ]is true and y axis if
|
||||
[%-*@3 vertical] is true to show all graphs data.on the control.
|
||||
[%-*@3 factor] indicates the fit factor (0 fills the control).&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s6; &]
|
||||
[s5;:ScatterDraw`:`:GetXMin`(`)const:%- [@(0.0.255) double]_[* GetXMin]_()_[@(0.0.255) cons
|
||||
t]&]
|
||||
[s3; Returns the X axis origin.&]
|
||||
|
|
@ -613,13 +708,7 @@ nst]&]
|
|||
nst]&]
|
||||
[s3; Returns the secondary Y axis origin.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetPolar`(bool`):%- [_^ScatterDraw^ ScatterDraw]_`&[* SetPolar]([@(0.0.255) b
|
||||
ool]_[*@3 polar]_`=_[@(0.0.255) true])&]
|
||||
[s3; If [%-*@3 polar] is true, ScatterDraw is converted into a Polar
|
||||
plot..&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s6; &]
|
||||
[s5;:ScatterDraw`:`:AddSeries`(double`*`,int`,double`,double`):%- [_^ScatterDraw^ Scatt
|
||||
erDraw]_`&[* AddSeries]([@(0.0.255) double]_`*[*@3 yData], [@(0.0.255) int]_[*@3 numData],
|
||||
[@(0.0.255) double]_[*@3 x0]_`=_[@3 0], [@(0.0.255) double]_[*@3 deltaX]_`=_[@3 1])&]
|
||||
|
|
@ -639,7 +728,7 @@ with [%-*@3 numData].&]
|
|||
location during ScatterDraw life to avoid memory problems.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:AddSeries`(Vector`<double`>`&`,Vector`<double`>`&`):%- [_^ScatterDraw^ S
|
||||
[s5;:ScatterDraw`:`:AddSeries`(Upp`:`:Vector`<double`>`&`,Upp`:`:Vector`<double`>`&`):%- [_^ScatterDraw^ S
|
||||
catterDraw]_`&[* AddSeries]([_^Vector^ Vector]<[@(0.0.255) double]>_`&[*@3 xData],
|
||||
[_^Vector^ Vector]<[@(0.0.255) double]>_`&[*@3 yData])&]
|
||||
[s3; Adds a new series stored in [%-*@3 xData] and [%-*@3 yData] [%-_^Vector^ Vector][%- <][%-@(0.0.255) d
|
||||
|
|
@ -648,7 +737,7 @@ ouble][%- >].&]
|
|||
location during ScatterDraw life to avoid memory problems.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:AddSeries`(Array`<double`>`&`,Array`<double`>`&`):%- [_^ScatterDraw^ S
|
||||
[s5;:ScatterDraw`:`:AddSeries`(Upp`:`:Array`<double`>`&`,Upp`:`:Array`<double`>`&`):%- [_^ScatterDraw^ S
|
||||
catterDraw]_`&[* AddSeries]([_^Array^ Array]<[@(0.0.255) double]>_`&[*@3 xData],
|
||||
[_^Array^ Array]<[@(0.0.255) double]>_`&[*@3 yData])&]
|
||||
[s3; Adds a new series stored in [%-*@3 xData] and [%-*@3 yData] [%-_^Vector^ Array][%- <][%-@(0.0.255) d
|
||||
|
|
@ -657,16 +746,16 @@ ouble][%- >].&]
|
|||
location during ScatterDraw life to avoid memory problems.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:AddSeries`(Vector`<Pointf`>`&`):%- [_^ScatterDraw^ ScatterDraw]_`&[* A
|
||||
ddSeries]([_^Vector^ Vector]<[_^Pointf^ Pointf]>_`&[*@3 points])&]
|
||||
[s5;:ScatterDraw`:`:AddSeries`(Upp`:`:Vector`<Upp`:`:Pointf`>`&`):%- [_^ScatterDraw^ Sc
|
||||
atterDraw]_`&[* AddSeries]([_^Vector^ Vector]<[_^Pointf^ Pointf]>_`&[*@3 points])&]
|
||||
[s3; Adds a new series stored in [%-*@3 points] [%-_^Vector^ Vector][%- <][%-_^Pointf^ Pointf
|
||||
][%- >].&]
|
||||
[s3; [%-*@3 points] has to be stored in a permanent location during
|
||||
ScatterDraw life to avoid memory problems.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:AddSeries`(Array`<Pointf`>`&`):%- [_^ScatterDraw^ ScatterDraw]_`&[* A
|
||||
ddSeries]([_^Array^ Array]<[_^Pointf^ Pointf]>_`&[*@3 points])&]
|
||||
[s5;:ScatterDraw`:`:AddSeries`(Upp`:`:Array`<Upp`:`:Pointf`>`&`):%- [_^ScatterDraw^ Sca
|
||||
tterDraw]_`&[* AddSeries]([_^Array^ Array]<[_^Pointf^ Pointf]>_`&[*@3 points])&]
|
||||
[s3; Adds a new series stored in [%-*@3 points] [%-_^Vector^ Array][%- <][%-_^Pointf^ Pointf][%- >
|
||||
].&]
|
||||
[s3; [%-*@3 points] has to be stored in a permanent location during
|
||||
|
|
@ -684,12 +773,12 @@ ouble]_[*@3 opacity]_`=_[@3 1])&]
|
|||
[s3; Sets the series [%-*@3 opacity] .from 1 (opaque) to 0 (transparent/invisible).&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:Legend`(const String`):%- [_^ScatterDraw^ ScatterDraw]_`&[* Legend]([@(0.0.255) c
|
||||
onst]_[_^String^ String]_[*@3 legend])&]
|
||||
[s5;:ScatterDraw`:`:Legend`(const Upp`:`:String`):%- [_^ScatterDraw^ ScatterDraw]_`&[* Le
|
||||
gend]([@(0.0.255) const]_[_^String^ String]_[*@3 legend])&]
|
||||
[s3; Sets the series [%-*@3 legend].&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:Legend`(int`,const String`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
[s5;:ScatterDraw`:`:Legend`(int`,const Upp`:`:String`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* Legend]([@(0.0.255) int]_[*@3 index], [@(0.0.255) const]_[_^String^ String]_[*@3 legend])
|
||||
&]
|
||||
[s3; Sets the [%-*@3 legend] for [%-*@3 index] series.&]
|
||||
|
|
@ -700,15 +789,15 @@ onst]_[_^String^ String]_[*@3 legend])&]
|
|||
[s3; Returns the legend for [%-*@3 index] series.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:Units`(const String`,const String`):%- [_^ScatterDraw^ ScatterDraw]_
|
||||
`&[* Units]([@(0.0.255) const]_[_^String^ String]_[*@3 unitsY], [@(0.0.255) const]_[_^String^ S
|
||||
tring]_[*@3 unitsX]_`=_`"`")&]
|
||||
[s5;:ScatterDraw`:`:Units`(const Upp`:`:String`,const Upp`:`:String`):%- [_^ScatterDraw^ S
|
||||
catterDraw]_`&[* Units]([@(0.0.255) const]_[_^String^ String]_[*@3 unitsY],
|
||||
[@(0.0.255) const]_[_^String^ String]_[*@3 unitsX]_`=_`"`")&]
|
||||
[s3; Sets the series units for Y axis ([%-*@3 unitsY]) and X axis ([%-*@3 unitsX]).&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:Units`(int`,const String`,const String`):%- [_^ScatterDraw^ Scatter
|
||||
Draw]_`&[* Units]([@(0.0.255) int]_[*@3 index], [@(0.0.255) const]_[_^String^ String]_[*@3 un
|
||||
itsY], [@(0.0.255) const]_[_^String^ String]_[*@3 unitsX]_`=_`"`")&]
|
||||
[s5;:ScatterDraw`:`:Units`(int`,const Upp`:`:String`,const Upp`:`:String`):%- [_^ScatterDraw^ S
|
||||
catterDraw]_`&[* Units]([@(0.0.255) int]_[*@3 index], [@(0.0.255) const]_[_^String^ String]_
|
||||
[*@3 unitsY], [@(0.0.255) const]_[_^String^ String]_[*@3 unitsX]_`=_`"`")&]
|
||||
[s3; Sets the [%-*@3 index] series units for Y axis ([%-*@3 unitsY])
|
||||
and X axis ([%-*@3 unitsX]).&]
|
||||
[s1; &]
|
||||
|
|
@ -723,6 +812,11 @@ and X axis ([%-*@3 unitsX]).&]
|
|||
[s3; Returns the Y axis units for [%-*@3 index] series.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:IsValid`(int`)const:%- [@(0.0.255) bool]_[* IsValid]([@(0.0.255) int]_[*@3 i
|
||||
ndex])_[@(0.0.255) const]&]
|
||||
[s3; Returns true if [%-*@3 index] is between 0 and GetCount()`-1..&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetDrawXReticle`(bool`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetDrawXReticle]([@(0.0.255) bool]_[*@3 set]_`=_[@(0.0.255) true])&]
|
||||
[s3; If [%-*@3 set] is true the small lines and texts beside every
|
||||
|
|
@ -732,34 +826,65 @@ X grid line are shown.&]
|
|||
[s5;:ScatterDraw`:`:SetDrawYReticle`(bool`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetDrawYReticle]([@(0.0.255) bool]_[*@3 set]_`=_[@(0.0.255) true])&]
|
||||
[s3; If [%-*@3 set] is true the small lines and texts to the left of
|
||||
every Y grid line are shown.&]
|
||||
every Y grid line are shown.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetDrawY2Reticle`(bool`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&
|
||||
]_[* SetDrawY2Reticle]([@(0.0.255) bool]_[*@3 set]_`=_[@(0.0.255) true])&]
|
||||
[s3; If [%-*@3 set] is true the small lines and texts to the right
|
||||
of every Y grid line are shown.&]
|
||||
of every Y grid line are shown.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetDrawXReticle`(`):%- [@(0.0.255) bool]_[* GetDrawXReticle]()&]
|
||||
[s3; Returns true if the the small lines and texts beside every X
|
||||
grid line are shown.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetDrawYReticle`(`):%- [@(0.0.255) bool]_[* GetDrawYReticle]()&]
|
||||
[s3; Returns true if the the small lines and texts to the left of
|
||||
every Y grid line are shown.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetDrawY2Reticle`(`):%- [@(0.0.255) bool]_[* GetDrawY2Reticle]()&]
|
||||
[s3; Returns true if the the small lines and texts to the right of
|
||||
every Y grid line are shown.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetDataPrimaryY`(int`,bool`):%- [@(0.0.255) void]_[* SetDataPrimaryY](
|
||||
[@(0.0.255) int]_[*@3 index], [@(0.0.255) bool]_[*@3 primary]_`=_[@(0.0.255) true])&]
|
||||
[s3; If [%-*@3 primary] is true, [%-*@3 index] series is considered to
|
||||
be a primary series so it uses the left vertical axis. If false
|
||||
it uses right vertical axis.&]
|
||||
it uses the right vertical axis.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetDataPrimaryY`(bool`):%- [_^ScatterDraw^ ScatterDraw]_`&[* SetDataP
|
||||
rimaryY]([@(0.0.255) bool]_[*@3 primary])&]
|
||||
[s3; If [%-*@3 primary] is true, last added series is considered to
|
||||
be a primary series so it uses the left vertical axis. If false
|
||||
it uses right vertical axis..&]
|
||||
be a primary series so it uses the left vertical axis. &]
|
||||
[s3; If false it uses the right vertical axis.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:IsDataPrimaryY`(int`)const throw`(Exc`):%- [@(0.0.255) bool]_[* IsDat
|
||||
aPrimaryY]([@(0.0.255) int]_[*@3 index])_[@(0.0.255) const]_[@(0.0.255) throw]_(Exc)&]
|
||||
[s3; Returns true if [%-*@3 index] series is primary.&]
|
||||
[s5;:ScatterDraw`:`:SetDataSecondaryY`(int`,bool`):%- [@(0.0.255) void]_[* SetDataSeconda
|
||||
ryY]([@(0.0.255) int]_[*@3 index], [@(0.0.255) bool]_[*@3 secondary])&]
|
||||
[s3; Opposed to SetDataPrimaryY() if [%-*@3 secondary] is true, [%-*@3 index]
|
||||
series is considered to be a secondary series so it uses the
|
||||
right vertical axis. &]
|
||||
[s3; If false it uses the left vertical axis.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:SetDataSecondaryY`(bool`):%- [_^ScatterDraw^ ScatterDraw]_`&[* SetDat
|
||||
aSecondaryY]([@(0.0.255) bool]_[*@3 secondary])&]
|
||||
[s3; Opposed to SetDataPrimaryY() if [%-*@3 secondary] is true, last
|
||||
added series is considered to be a secondary series so it uses
|
||||
the right vertical axis.&]
|
||||
[s3; If false it uses the left vertical axis.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:IsDataPrimaryY`(int`):%- [@(0.0.255) bool]_[* IsDataPrimaryY]([@(0.0.255) i
|
||||
nt]_[*@3 index])&]
|
||||
[s3; Returns true if [%-*@3 index] series is primary..&]
|
||||
[s1; &]
|
||||
[s6; &]
|
||||
[s5;:ScatterDraw`:`:SetSequentialX`(int`,bool`):%- [@(0.0.255) void]_[* SetSequentialX]([@(0.0.255) i
|
||||
nt]_[*@3 index], [@(0.0.255) bool]_[*@3 sequential]_`=_[@(0.0.255) true])&]
|
||||
[s3; If [%-*@3 sequential] is true, [%-*@3 index] series is considered
|
||||
|
|
@ -780,6 +905,17 @@ uentialXAll]([@(0.0.255) bool]_[*@3 sequential]_`=_[@(0.0.255) true])&]
|
|||
sequential so all data points are ordered following the X axis.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetSequentialX`(int`):%- [@(0.0.255) bool]_[* GetSequentialX]([@(0.0.255) i
|
||||
nt]_[*@3 index])&]
|
||||
[s3; Returns true if [%-*@3 index] data series is considered to be
|
||||
sequential so all data points are ordered following the X axis.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetSequentialX`(`):%- [@(0.0.255) bool]_[* GetSequentialX]()&]
|
||||
[s3; Returns true if the last added series is considered to be sequential
|
||||
so all data points are ordered following the X axis.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:Show`(int`,bool`):%- [@(0.0.255) void]_[* Show]([@(0.0.255) int]_[*@3 ind
|
||||
ex], [@(0.0.255) bool]_[*@3 show]_`=_[@(0.0.255) true])&]
|
||||
[s3; If [%-*@3 show] is true it sets the opacity of [%-*@3 index] data
|
||||
|
|
@ -809,6 +945,10 @@ the series data.&]
|
|||
series data.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetImage`(`):%- [_^Upp`:`:Image^ Image]_[* GetImage]()&]
|
||||
[s3; Returns the scatter plot as an Image.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:Id`(int`):%- [_^ScatterDraw^ ScatterDraw][@(0.0.255) `&]_[* Id]([@(0.0.255) i
|
||||
nt]_[*@3 id])&]
|
||||
[s3; Sets the [%-*@3 id] of the last added data series.&]
|
||||
|
|
@ -823,15 +963,10 @@ nt]_[*@3 index], [@(0.0.255) int]_[*@3 id])&]
|
|||
[s3; Returns the id of [%-*@3 index] data series.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetDrawing`(bool`):%- [_^Drawing^ Drawing]_[* GetDrawing]()&]
|
||||
[s5;:ScatterDraw`:`:GetDrawing`(`):%- [_^Drawing^ Drawing]_[* GetDrawing]()&]
|
||||
[s3; Returns the control Drawing.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetImage`(int`):%- [_^Image^ Image]_[* GetImage]([@(0.0.255) int]_[*@3 sc
|
||||
ale]_`=_[@3 1])&]
|
||||
[s3; Returns the control Image scaled at [%-*@3 scale].&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s6; &]
|
||||
[s5;:ScatterDraw`:`:GetXByPoint`(double`):%- [@(0.0.255) double]_[* GetXByPoint]([@(0.0.255) d
|
||||
ouble]_[*@3 x])&]
|
||||
[s3; Returns the X axis value of pixel [%-*@3 x] in data set units.&]
|
||||
|
|
@ -899,6 +1034,10 @@ points between two pixels.&]
|
|||
can accelerate strongly the control refresh.&]
|
||||
[s1; &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetFastViewX`(`):%- [@(0.0.255) bool]_[* GetFastViewX]()&]
|
||||
[s3; Returns true if FastViewX has been set.&]
|
||||
[s1;%- &]
|
||||
[s6;%- &]
|
||||
[s5;:ScatterDraw`:`:GetCount`(`):%- [@(0.0.255) int]_[* GetCount]()&]
|
||||
[s3; Returns the number of series loaded.&]
|
||||
[s1;%- &]
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue