Hello,
I tried to run TestScatter2, but it is stuck in infinite loops in Scatter::SetRange and Scatter::SetMajorUnits. Callers are scatter2.SetRange(12,60) and scatter2.SetMajorUnits(2,10) in Tab2::Tab2().
I am using UPP2232, MSC8, on XP.
I use magic numbers to solve the problem, but I bet there are better solutions, if I understand the meaning of those members.
After the hack, the example looks great! Thanks!
Scatter &Scatter::SetRange(double rx, double ry, double ry2)
{
xRange=rx;
yRange=ry;
yRange2=ry2;
xMajorUnit=xRange/10;
int count=0;
while (xMinUnit > xMajorUnit && count < 1000){
xMinUnit -= xMajorUnit;
++count;
}
yMajorUnit=yRange/10;
count = 0;
while (yMinUnit > yMajorUnit && count < 1000){
yMinUnit -= yMajorUnit;
++count;
}
yMajorUnit2=yRange2/10;
count = 0;
while (yMinUnit2 > yMajorUnit2 && count < 1000) {
yMinUnit2 -= yMajorUnit2;
++count;
}
return *this;
}
Scatter &Scatter::SetMajorUnits(double ux, double uy)
{
//if (ux > xRange) throw (Exc(t_("Invalid X major units!")));
//if (uy > yRange) throw (Exc(t_("Invalid Y major units!")));
xMajorUnit=ux;
yMajorUnit=uy;
yMajorUnit2=yRange2*yMajorUnit/yRange;
int count=0;
while (xMinUnit > xMajorUnit && count < 1000){
xMinUnit -= xMajorUnit;
++count;
}
count = 0;
while (yMinUnit > yMajorUnit && count < 1000){
yMinUnit -= yMajorUnit;
++count;
}
count = 0;
while (yMinUnit2 > yMajorUnit2 && count < 1000){
yMinUnit2 -= yMajorUnit2;
++count;
}
return *this;
}
|