summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorAdrián Medraño Calvo <adrian@medranocalvo.com>2017-07-21 09:20:28 (GMT)
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2017-07-21 11:40:48 (GMT)
commitf14d9dc7c790f40e897bf4f3afaacdde6509adac (patch)
tree9decc8ccfb18a38a94568feea8c9dc66e4ff6fd2 /generic
parent095e27e5a9b983b7a20ea6bc4b9f4989ddb9a160 (diff)
downloadblt-f14d9dc7c790f40e897bf4f3afaacdde6509adac.zip
blt-f14d9dc7c790f40e897bf4f3afaacdde6509adac.tar.gz
blt-f14d9dc7c790f40e897bf4f3afaacdde6509adac.tar.bz2
Enforce explicit downcasting of numeric values
As part of the change, upgrade tkblt internal structures from short/float to int/double, as those are artifacts of the legacy code relying on X. Downcast to short at the latest stage: when interfacing with X.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkbltGrAxis.C24
-rw-r--r--generic/tkbltGrAxis.h20
-rw-r--r--generic/tkbltGrElem.h4
-rw-r--r--generic/tkbltGrElemBar.C38
-rw-r--r--generic/tkbltGrElemBar.h14
-rw-r--r--generic/tkbltGrElemLine.C90
-rw-r--r--generic/tkbltGrHairs.h2
-rw-r--r--generic/tkbltGrLegd.C16
-rw-r--r--generic/tkbltGrMarkerPolygon.C4
-rw-r--r--generic/tkbltGrMarkerText.C8
-rw-r--r--generic/tkbltGrMisc.h9
-rw-r--r--generic/tkbltGrPSOutput.C40
-rw-r--r--generic/tkbltGrPSOutput.h2
-rw-r--r--generic/tkbltGrPostscript.h10
-rw-r--r--generic/tkbltGrText.C19
-rw-r--r--generic/tkbltGrText.h2
-rw-r--r--generic/tkbltGraph.C12
-rw-r--r--generic/tkbltGraph.h32
-rw-r--r--generic/tkbltGraphOp.C4
-rw-r--r--generic/tkbltVector.C2
20 files changed, 186 insertions, 166 deletions
diff --git a/generic/tkbltGrAxis.C b/generic/tkbltGrAxis.C
index d6b36a8..145f380 100644
--- a/generic/tkbltGrAxis.C
+++ b/generic/tkbltGrAxis.C
@@ -395,8 +395,8 @@ int Axis::configure()
if (ops->title) {
int w, h;
graphPtr_->getTextExtents(ops->titleFont, ops->title, -1, &w, &h);
- titleWidth_ = (unsigned short int)w;
- titleHeight_ = (unsigned short int)h;
+ titleWidth_ = (unsigned int)w;
+ titleHeight_ = (unsigned int)h;
}
return TCL_OK;
@@ -598,7 +598,7 @@ void Axis::draw(Drawable drawable)
max_ = EXP10(max_);
}
updateScrollbar(graphPtr_->interp_, ops->scrollCmdObjPtr,
- viewMin, viewMax, worldWidth);
+ (int)viewMin, (int)viewMax, (int)worldWidth);
}
else {
viewMax = (fract * worldWidth);
@@ -610,7 +610,7 @@ void Axis::draw(Drawable drawable)
max_ = EXP10(max_);
}
updateScrollbar(graphPtr_->interp_, ops->scrollCmdObjPtr,
- viewMax, viewMin, worldWidth);
+ (int)viewMax, (int)viewMin, (int)worldWidth);
}
}
@@ -783,7 +783,7 @@ void Axis::logScale(double min, double max)
minorStep = 0.2;
}
else
- nMinor = (majorStep/minorStep) - 1;
+ nMinor = (int)(majorStep/minorStep) - 1;
}
else {
if (tickMin == tickMax)
@@ -841,7 +841,7 @@ void Axis::linearScale(double min, double max)
axisMin = tickMin = floor(min / step) * step + 0.0;
axisMax = tickMax = ceil(max / step) * step + 0.0;
- nTicks = ((tickMax-tickMin) / step) + 1;
+ nTicks = (int)((tickMax-tickMin) / step) + 1;
}
majorSweep_.step = step;
majorSweep_.initial = tickMin;
@@ -1814,14 +1814,14 @@ void Axis::printLimits(PSOutput* psPtr)
ops->limitsTextStyle.angle = 90.0;
ops->limitsTextStyle.anchor = TK_ANCHOR_SE;
- ts.printText(psPtr, maxPtr, (double)graphPtr_->right_, hMax);
+ ts.printText(psPtr, maxPtr, graphPtr_->right_, (int)hMax);
hMax -= (textWidth + spacing);
}
else {
ops->limitsTextStyle.angle = 0.0;
ops->limitsTextStyle.anchor = TK_ANCHOR_NW;
- ts.printText(psPtr, maxPtr, vMax, (double)graphPtr_->top_);
+ ts.printText(psPtr, maxPtr, (int)vMax, graphPtr_->top_);
vMax += (textWidth + spacing);
}
}
@@ -1836,13 +1836,13 @@ void Axis::printLimits(PSOutput* psPtr)
if (isHoriz) {
ops->limitsTextStyle.angle = 90.0;
- ts.printText(psPtr, minPtr, (double)graphPtr_->left_, hMin);
+ ts.printText(psPtr, minPtr, graphPtr_->left_, (int)hMin);
hMin -= (textWidth + spacing);
}
else {
ops->limitsTextStyle.angle = 0.0;
- ts.printText(psPtr, minPtr, vMin, (double)graphPtr_->bottom_);
+ ts.printText(psPtr, minPtr, (int)vMin, graphPtr_->bottom_);
vMin += (textWidth + spacing);
}
}
@@ -1922,8 +1922,8 @@ void Axis::getGeometry()
// Rotated label width and height
double rlw, rlh;
graphPtr_->getBoundingBox(lw, lh, ops->tickAngle, &rlw, &rlh, NULL);
- lw = rlw;
- lh = rlh;
+ lw = (int)rlw;
+ lh = (int)rlh;
}
if (maxTickWidth_ < int(lw))
maxTickWidth_ = lw;
diff --git a/generic/tkbltGrAxis.h b/generic/tkbltGrAxis.h
index 2e35d3f..90a1165 100644
--- a/generic/tkbltGrAxis.h
+++ b/generic/tkbltGrAxis.h
@@ -175,8 +175,8 @@ namespace Blt {
Chain* chain;
Point2d titlePos_;
- unsigned short int titleWidth_;
- unsigned short int titleHeight_;
+ unsigned int titleWidth_;
+ unsigned int titleHeight_;
double min_;
double max_;
double scrollMin_;
@@ -194,14 +194,14 @@ namespace Blt {
Segment2d *segments_;
int nSegments_;
Chain* tickLabels_;
- short int left_;
- short int right_;
- short int top_;
- short int bottom_;
- short int width_;
- short int height_;
- short int maxTickWidth_;
- short int maxTickHeight_;
+ int left_;
+ int right_;
+ int top_;
+ int bottom_;
+ int width_;
+ int height_;
+ int maxTickWidth_;
+ int maxTickHeight_;
Tk_Anchor tickAnchor_;
GC tickGC_;
GC activeTickGC_;
diff --git a/generic/tkbltGrElem.h b/generic/tkbltGrElem.h
index eabc9e9..8904df0 100644
--- a/generic/tkbltGrElem.h
+++ b/generic/tkbltGrElem.h
@@ -156,8 +156,8 @@ namespace Blt {
Graph* graphPtr_;
const char* name_;
Tcl_HashEntry* hashPtr_;
- unsigned short row_;
- unsigned short col_;
+ unsigned row_;
+ unsigned col_;
int nActiveIndices_;
int* activeIndices_;
int active_;
diff --git a/generic/tkbltGrElemBar.C b/generic/tkbltGrElemBar.C
index a1b1f12..bdd36d8 100644
--- a/generic/tkbltGrElemBar.C
+++ b/generic/tkbltGrElemBar.C
@@ -279,7 +279,7 @@ void BarElement::map()
// Create an array of bars representing the screen coordinates of all the
// segments in the bar.
- XRectangle* bars = new XRectangle[nPoints];
+ Rectangle* bars = new Rectangle[nPoints];
int* barToData = new int[nPoints];
double* x = ops->coords.x->values_;
@@ -287,7 +287,7 @@ void BarElement::map()
int count = 0;
int ii;
- XRectangle* rp;
+ Rectangle* rp;
for (rp=bars, ii=0; ii<nPoints; ii++) {
// Two opposite corners of the rectangle in graph coordinates
Point2d c1, c2;
@@ -428,13 +428,15 @@ void BarElement::map()
continue;
int height = (int)dy;
+ int width = (int)dx;
if (invertBar)
- rp->y = (short int)MIN(c1.y, c2.y);
+ rp->y = (int)MIN(c1.y, c2.y);
else
- rp->y = (short int)(MAX(c1.y, c2.y)) - height;
+ rp->y = (int)(MAX(c1.y, c2.y)) - height;
- rp->x = (short int)MIN(c1.x, c2.x);
- rp->width = (short int)dx + 1;
+ rp->x = (int)MIN(c1.x, c2.x);
+
+ rp->width = width + 1;
rp->width |= 0x1;
if (rp->width < 1)
rp->width = 1;
@@ -621,7 +623,7 @@ void BarElement::closest()
int imin = 0;
int ii;
- XRectangle* bp;
+ Rectangle* bp;
for (bp=bars_, ii=0; ii<nBars_; ii++, bp++) {
if (PointInRectangle(bp, searchPtr->x, searchPtr->y)) {
imin = barToData_[ii];
@@ -904,9 +906,9 @@ void BarElement::mergePens(BarStyle** dataToStyle)
// We have more than one style. Group bar segments of like pen styles together
if (nBars_ > 0) {
- XRectangle* bars = new XRectangle[nBars_];
+ Rectangle* bars = new Rectangle[nBars_];
int* barToData = new int[nBars_];
- XRectangle* bp = bars;
+ Rectangle* bp = bars;
int* ip = barToData;
for (ChainLink* link = Chain_FirstLink(ops->stylePalette); link;
link = Chain_NextLink(link)) {
@@ -990,7 +992,7 @@ void BarElement::mapActive()
nActive_ = 0;
if (nActiveIndices_ > 0) {
- XRectangle* activeRects = new XRectangle[nActiveIndices_];
+ Rectangle* activeRects = new Rectangle[nActiveIndices_];
int* activeToData = new int[nActiveIndices_];
int count = 0;
for (int ii=0; ii<nBars_; ii++) {
@@ -1189,10 +1191,10 @@ void BarElement::mapErrorBars(BarStyle **dataToStyle)
}
void BarElement::drawSegments(Drawable drawable, BarPen* penPtr,
- XRectangle *bars, int nBars)
+ Rectangle *bars, int nBars)
{
BarPenOptions* pops = (BarPenOptions*)penPtr->ops();
- for (XRectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) {
+ for (Rectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) {
if ((rp->width < 1) || (rp->height < 1))
continue;
@@ -1207,7 +1209,7 @@ void BarElement::drawSegments(Drawable drawable, BarPen* penPtr,
}
void BarElement::drawValues(Drawable drawable, BarPen* penPtr,
- XRectangle *bars, int nBars, int *barToData)
+ Rectangle *bars, int nBars, int *barToData)
{
BarElementOptions* ops = (BarElementOptions*)ops_;
BarPenOptions* pops = (BarPenOptions*)penPtr->ops();
@@ -1219,7 +1221,7 @@ void BarElement::drawValues(Drawable drawable, BarPen* penPtr,
TextStyle ts(graphPtr_, &pops->valueStyle);
int count = 0;
- for (XRectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) {
+ for (Rectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) {
Point2d anchorPos;
char string[TCL_DOUBLE_SPACE * 2 + 2];
@@ -1255,10 +1257,10 @@ void BarElement::drawValues(Drawable drawable, BarPen* penPtr,
}
void BarElement::printSegments(PSOutput* psPtr, BarPen* penPtr,
- XRectangle *bars, int nBars)
+ Rectangle *bars, int nBars)
{
BarPenOptions* pops = (BarPenOptions*)penPtr->ops();
- for (XRectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) {
+ for (Rectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) {
if ((rp->width < 1) || (rp->height < 1))
continue;
@@ -1275,7 +1277,7 @@ void BarElement::printSegments(PSOutput* psPtr, BarPen* penPtr,
}
void BarElement::printValues(PSOutput* psPtr, BarPen* penPtr,
- XRectangle *bars, int nBars, int *barToData)
+ Rectangle *bars, int nBars, int *barToData)
{
BarPenOptions* pops = (BarPenOptions*)penPtr->ops();
BarElementOptions* ops = (BarElementOptions*)ops_;
@@ -1287,7 +1289,7 @@ void BarElement::printValues(PSOutput* psPtr, BarPen* penPtr,
fmt = "%g";
TextStyle ts(graphPtr_, &pops->valueStyle);
- for (XRectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) {
+ for (Rectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) {
double x = ops->coords.x->values_[barToData[count]];
double y = ops->coords.y->values_[barToData[count]];
diff --git a/generic/tkbltGrElemBar.h b/generic/tkbltGrElemBar.h
index 9207a9f..8b48114 100644
--- a/generic/tkbltGrElemBar.h
+++ b/generic/tkbltGrElemBar.h
@@ -49,7 +49,7 @@ namespace Blt {
typedef struct {
Weight weight;
BarPen* penPtr;
- XRectangle* bars;
+ Rectangle* bars;
int nBars;
GraphSegments xeb;
GraphSegments yeb;
@@ -88,9 +88,9 @@ namespace Blt {
protected:
BarPen* builtinPenPtr;
int* barToData_;
- XRectangle* bars_;
+ Rectangle* bars_;
int* activeToData_;
- XRectangle* activeRects_;
+ Rectangle* activeRects_;
int nBars_;
int nActive_;
GraphSegments xeb_;
@@ -103,10 +103,10 @@ namespace Blt {
void mapActive();
void reset();
void mapErrorBars(BarStyle**);
- void drawSegments(Drawable, BarPen*, XRectangle*, int);
- void drawValues(Drawable, BarPen*, XRectangle*, int, int*);
- void printSegments(PSOutput*, BarPen*, XRectangle*, int);
- void printValues(PSOutput*, BarPen*, XRectangle*, int, int*);
+ void drawSegments(Drawable, BarPen*, Rectangle*, int);
+ void drawValues(Drawable, BarPen*, Rectangle*, int, int*);
+ void printSegments(PSOutput*, BarPen*, Rectangle*, int);
+ void printValues(PSOutput*, BarPen*, Rectangle*, int, int*);
public:
BarElement(Graph*, const char*, Tcl_HashEntry*);
diff --git a/generic/tkbltGrElemLine.C b/generic/tkbltGrElemLine.C
index 8da4279..bf81d69 100644
--- a/generic/tkbltGrElemLine.C
+++ b/generic/tkbltGrElemLine.C
@@ -526,8 +526,8 @@ void LineElement::draw(Drawable drawable)
unsigned int count =0;
for (Point2d *pp = fillPts_, *endp = pp + nFillPts_; pp < endp; pp++) {
- points[count].x = pp->x;
- points[count].y = pp->y;
+ points[count].x = (short)pp->x;
+ points[count].y = (short)pp->y;
count++;
}
Tk_Fill3DPolygon(graphPtr_->tkwin_, drawable, ops->fillBg, points,
@@ -925,11 +925,9 @@ int LineElement::scaleSymbol(int normalSize)
scale = MIN(xScale, yScale);
}
}
- int newSize = normalSize * scale;
+ int newSize = (int)(normalSize * scale);
- // Don't let the size of symbols go unbounded. Both X and Win32 drawing
- // routines assume coordinates to be a signed short int.
- int maxSize = (int)MIN(graphPtr_->hRange_, graphPtr_->vRange_);
+ int maxSize = MIN(graphPtr_->hRange_, graphPtr_->vRange_);
if (newSize > maxSize)
newSize = maxSize;
@@ -1952,10 +1950,10 @@ void LineElement::drawCircle(Display *display, Drawable drawable,
XArc *ap = arcs;
for (Point2d *pp=symbolPts, *pend=pp+nSymbolPts; pp<pend; pp++) {
if (DRAW_SYMBOL()) {
- ap->x = pp->x - radius;
- ap->y = pp->y - radius;
- ap->width = (unsigned short)s;
- ap->height = (unsigned short)s;
+ ap->x = (short)(pp->x - radius);
+ ap->y = (short)(pp->y - radius);
+ ap->width = (short)s;
+ ap->height = (short)s;
ap->angle1 = 0;
ap->angle2 = 23040;
ap++;
@@ -1985,21 +1983,21 @@ void LineElement::drawSquare(Display *display, Drawable drawable,
int s = r + r;
int count =0;
- XRectangle* rectangles = new XRectangle[nSymbolPts];
- XRectangle* rp=rectangles;
+ Rectangle* rectangles = new Rectangle[nSymbolPts];
+ Rectangle* rp=rectangles;
for (Point2d *pp=symbolPts, *pend=pp+nSymbolPts; pp<pend; pp++) {
if (DRAW_SYMBOL()) {
- rp->x = pp->x - r;
- rp->y = pp->y - r;
- rp->width = (unsigned short)s;
- rp->height = (unsigned short)s;
+ rp->x = (int)pp->x - r;
+ rp->y = (int)pp->y - r;
+ rp->width = s;
+ rp->height = s;
rp++;
count++;
}
symbolCounter_++;
}
- for (XRectangle *rp=rectangles, *rend=rp+count; rp<rend; rp ++) {
+ for (Rectangle *rp=rectangles, *rend=rp+count; rp<rend; rp ++) {
if (penOps->symbol.fillGC)
XFillRectangle(display, drawable, penOps->symbol.fillGC,
rp->x, rp->y, rp->width, rp->height);
@@ -2018,9 +2016,9 @@ void LineElement::drawSCross(Display* display, Drawable drawable,
{
LinePenOptions* penOps = (LinePenOptions*)penPtr->ops();
- XPoint pattern[4];
+ Point pattern[4];
if (penOps->symbol.type == SYMBOL_SCROSS) {
- r2 = (double)r2 * M_SQRT1_2;
+ r2 = (int)(r2 * M_SQRT1_2);
pattern[3].y = pattern[2].x = pattern[0].x = pattern[0].y = -r2;
pattern[3].x = pattern[2].y = pattern[1].y = pattern[1].x = r2;
}
@@ -2032,8 +2030,8 @@ void LineElement::drawSCross(Display* display, Drawable drawable,
for (Point2d *pp=symbolPts, *endp=pp+nSymbolPts; pp<endp; pp++) {
if (DRAW_SYMBOL()) {
- int rndx = pp->x;
- int rndy = pp->y;
+ int rndx = (int)pp->x;
+ int rndy = (int)pp->y;
XDrawLine(graphPtr_->display_, drawable, penOps->symbol.outlineGC,
pattern[0].x + rndx, pattern[0].y + rndy,
pattern[1].x + rndx, pattern[1].y + rndy);
@@ -2060,14 +2058,14 @@ void LineElement::drawCross(Display *display, Drawable drawable,
* 9 8
*/
int d = (r2 / 3);
- XPoint pattern[13];
+ Point pattern[13];
pattern[0].x = pattern[11].x = pattern[12].x = -r2;
pattern[2].x = pattern[1].x = pattern[10].x = pattern[9].x = -d;
pattern[3].x = pattern[4].x = pattern[7].x = pattern[8].x = d;
pattern[5].x = pattern[6].x = r2;
pattern[2].y = pattern[3].y = -r2;
pattern[0].y = pattern[1].y = pattern[4].y = pattern[5].y =
- pattern[12].y = -d;
+ pattern[12].y = -d;
pattern[11].y = pattern[10].y = pattern[7].y = pattern[6].y = d;
pattern[9].y = pattern[8].y = r2;
@@ -2076,8 +2074,8 @@ void LineElement::drawCross(Display *display, Drawable drawable,
for (int ii=0; ii<12; ii++) {
double dx = (double)pattern[ii].x * M_SQRT1_2;
double dy = (double)pattern[ii].y * M_SQRT1_2;
- pattern[ii].x = dx - dy;
- pattern[ii].y = dx + dy;
+ pattern[ii].x = (int)(dx - dy);
+ pattern[ii].y = (int)(dx + dy);
}
pattern[12] = pattern[0];
}
@@ -2087,11 +2085,11 @@ void LineElement::drawCross(Display *display, Drawable drawable,
XPoint* xpp = polygon;
for (Point2d *pp = symbolPts, *endp = pp + nSymbolPts; pp < endp; pp++) {
if (DRAW_SYMBOL()) {
- int rndx = pp->x;
- int rndy = pp->y;
+ int rndx = (int)pp->x;
+ int rndy = (int)pp->y;
for (int ii=0; ii<13; ii++) {
- xpp->x = pattern[ii].x + rndx;
- xpp->y = pattern[ii].y + rndy;
+ xpp->x = (short)(pattern[ii].x + rndx);
+ xpp->y = (short)(pattern[ii].y + rndy);
xpp++;
}
count++;
@@ -2131,7 +2129,7 @@ void LineElement::drawDiamond(Display *display, Drawable drawable,
* (fifth) point connects the first and
* 3 last points.
*/
- XPoint pattern[5];
+ Point pattern[5];
pattern[1].y = pattern[0].x = -r1;
pattern[2].y = pattern[3].x = pattern[0].y = pattern[1].x = 0;
pattern[3].y = pattern[2].x = r1;
@@ -2142,11 +2140,11 @@ void LineElement::drawDiamond(Display *display, Drawable drawable,
XPoint* xpp = polygon;
for (Point2d *pp = symbolPts, *endp = pp + nSymbolPts; pp < endp; pp++) {
if (DRAW_SYMBOL()) {
- int rndx = pp->x;
- int rndy = pp->y;
+ int rndx = (int)pp->x;
+ int rndy = (int)pp->y;
for (int ii=0; ii<5; ii++) {
- xpp->x = pattern[ii].x + rndx;
- xpp->y = pattern[ii].y + rndy;
+ xpp->x = (short)(pattern[ii].x + rndx);
+ xpp->y = (short)(pattern[ii].y + rndy);
xpp++;
}
count++;
@@ -2180,10 +2178,10 @@ void LineElement::drawArrow(Display *display, Drawable drawable,
{
LinePenOptions* penOps = (LinePenOptions*)penPtr->ops();
- double b = size * B_RATIO * 0.7;
- int b2 = b * 0.5;
- int h2 = TAN30 * b2;
- int h1 = b2 / COS30;
+ double b = size * B_RATIO * 0.7 * 0.5;
+ short b2 = (short)b;
+ short h2 = (short)(TAN30 * b);
+ short h1 = (short)(b / COS30);
/*
* The triangle symbol is a closed polygon
* 0,3 of 3 points. The diagram to the left
@@ -2193,7 +2191,7 @@ void LineElement::drawArrow(Display *display, Drawable drawable,
* 2 1 last points.
*/
- XPoint pattern[4];
+ Point pattern[4];
if (penOps->symbol.type == SYMBOL_ARROW) {
pattern[3].x = pattern[0].x = 0;
pattern[3].y = pattern[0].y = h1;
@@ -2213,11 +2211,11 @@ void LineElement::drawArrow(Display *display, Drawable drawable,
XPoint* xpp = polygon;
for (Point2d *pp = symbolPts, *endp = pp + nSymbolPts; pp < endp; pp++) {
if (DRAW_SYMBOL()) {
- int rndx = pp->x;
- int rndy = pp->y;
+ int rndx = (int)pp->x;
+ int rndy = (int)pp->y;
for (int ii=0; ii<4; ii++) {
- xpp->x = pattern[ii].x + rndx;
- xpp->y = pattern[ii].y + rndy;
+ xpp->x = (short)(pattern[ii].x + rndx);
+ xpp->y = (short)(pattern[ii].y + rndy);
xpp++;
}
count++;
@@ -2252,7 +2250,7 @@ void LineElement::drawSymbols(Drawable drawable, LinePen* penPtr, int size,
if (penOps->symbol.fillGC) {
for (Point2d *pp = symbolPts, *endp = pp + nSymbolPts; pp < endp; pp++)
XDrawLine(graphPtr_->display_, drawable, penOps->symbol.fillGC,
- pp->x, pp->y, pp->x+1, pp->y+1);
+ (int)pp->x, (int)pp->y, (int)pp->x+1, (int)pp->y+1);
}
return;
}
@@ -2297,8 +2295,8 @@ void LineElement::drawTraces(Drawable drawable, LinePen* penPtr)
XPoint* points = new XPoint[count];
XPoint*xpp = points;
for (int ii=0; ii<count; ii++, xpp++) {
- xpp->x = tracePtr->screenPts.points[ii].x;
- xpp->y = tracePtr->screenPts.points[ii].y;
+ xpp->x = (short)tracePtr->screenPts.points[ii].x;
+ xpp->y = (short)tracePtr->screenPts.points[ii].y;
}
XDrawLines(graphPtr_->display_, drawable, penPtr->traceGC_, points,
count, CoordModeOrigin);
diff --git a/generic/tkbltGrHairs.h b/generic/tkbltGrHairs.h
index 825cf2a..a86d0c6 100644
--- a/generic/tkbltGrHairs.h
+++ b/generic/tkbltGrHairs.h
@@ -56,7 +56,7 @@ namespace Blt {
int visible_;
GC gc_;
- XPoint segArr_[4];
+ Point segArr_[4];
public:
Crosshairs(Graph*);
diff --git a/generic/tkbltGrLegd.C b/generic/tkbltGrLegd.C
index 5242215..3b08f23 100644
--- a/generic/tkbltGrLegd.C
+++ b/generic/tkbltGrLegd.C
@@ -878,8 +878,8 @@ int Legend::getElementFromObj(Tcl_Obj* objPtr, Element** elemPtrPtr)
Element* Legend::getNextRow(Element* focusPtr)
{
- int col = focusPtr->col_;
- int row = focusPtr->row_ + 1;
+ unsigned col = focusPtr->col_;
+ unsigned row = focusPtr->row_ + 1;
for (ChainLink* link = focusPtr->link; link; link = Chain_NextLink(link)) {
Element* elemPtr = (Element*)Chain_GetValue(link);
ElementOptions* elemOps = (ElementOptions*)elemPtr->ops();
@@ -895,8 +895,8 @@ Element* Legend::getNextRow(Element* focusPtr)
Element* Legend::getNextColumn(Element* focusPtr)
{
- int col = focusPtr->col_ + 1;
- int row = focusPtr->row_;
+ unsigned col = focusPtr->col_ + 1;
+ unsigned row = focusPtr->row_;
for (ChainLink* link = focusPtr->link; link; link = Chain_NextLink(link)) {
Element* elemPtr = (Element*)Chain_GetValue(link);
ElementOptions* elemOps = (ElementOptions*)elemPtr->ops();
@@ -912,8 +912,8 @@ Element* Legend::getNextColumn(Element* focusPtr)
Element* Legend::getPreviousRow(Element* focusPtr)
{
- int col = focusPtr->col_;
- int row = focusPtr->row_ - 1;
+ unsigned col = focusPtr->col_;
+ unsigned row = focusPtr->row_ - 1;
for (ChainLink* link = focusPtr->link; link; link = Chain_PrevLink(link)) {
Element* elemPtr = (Element*)Chain_GetValue(link);
ElementOptions* elemOps = (ElementOptions*)elemPtr->ops();
@@ -929,8 +929,8 @@ Element* Legend::getPreviousRow(Element* focusPtr)
Element* Legend::getPreviousColumn(Element* focusPtr)
{
- int col = focusPtr->col_ - 1;
- int row = focusPtr->row_;
+ unsigned col = focusPtr->col_ - 1;
+ unsigned row = focusPtr->row_;
for (ChainLink* link = focusPtr->link; link; link = Chain_PrevLink(link)) {
Element* elemPtr = (Element*)Chain_GetValue(link);
ElementOptions* elemOps = (ElementOptions*)elemPtr->ops();
diff --git a/generic/tkbltGrMarkerPolygon.C b/generic/tkbltGrMarkerPolygon.C
index ed655aa..3b67272 100644
--- a/generic/tkbltGrMarkerPolygon.C
+++ b/generic/tkbltGrMarkerPolygon.C
@@ -164,8 +164,8 @@ void PolygonMarker::draw(Drawable drawable)
XPoint* dp = points;
for (Point2d *sp = fillPts_, *send = sp + nFillPts_; sp < send; sp++) {
- dp->x = (short int)sp->x;
- dp->y = (short int)sp->y;
+ dp->x = (short)sp->x;
+ dp->y = (short)sp->y;
dp++;
}
diff --git a/generic/tkbltGrMarkerText.C b/generic/tkbltGrMarkerText.C
index 5afa6ca..9c4da2a 100644
--- a/generic/tkbltGrMarkerText.C
+++ b/generic/tkbltGrMarkerText.C
@@ -148,8 +148,8 @@ void TextMarker::draw(Drawable drawable)
if (fillGC_) {
XPoint points[4];
for (int ii=0; ii<4; ii++) {
- points[ii].x = (short int)(outline_[ii].x + anchorPt_.x);
- points[ii].y = (short int)(outline_[ii].y + anchorPt_.y);
+ points[ii].x = (short)(outline_[ii].x + anchorPt_.x);
+ points[ii].y = (short)(outline_[ii].y + anchorPt_.y);
}
XFillPolygon(graphPtr_->display_, drawable, fillGC_, points, 4,
Convex, CoordModeOrigin);
@@ -179,8 +179,8 @@ void TextMarker::map()
double rw;
double rh;
graphPtr_->getBoundingBox(w, h, ops->style.angle, &rw, &rh, outline_);
- width_ = rw;
- height_ = rh;
+ width_ = (int)rw;
+ height_ = (int)rh;
for (int ii=0; ii<4; ii++) {
outline_[ii].x += rw * 0.5;
outline_[ii].y += rh * 0.5;
diff --git a/generic/tkbltGrMisc.h b/generic/tkbltGrMisc.h
index b7c521f..ba86b75 100644
--- a/generic/tkbltGrMisc.h
+++ b/generic/tkbltGrMisc.h
@@ -68,6 +68,15 @@ namespace Blt {
class Graph;
typedef struct {
+ int x, y;
+ } Point;
+
+ typedef struct {
+ int x, y;
+ unsigned width, height;
+ } Rectangle;
+
+ typedef struct {
double x;
double y;
} Point2d;
diff --git a/generic/tkbltGrPSOutput.C b/generic/tkbltGrPSOutput.C
index 8f02cba..07d4864 100644
--- a/generic/tkbltGrPSOutput.C
+++ b/generic/tkbltGrPSOutput.C
@@ -144,46 +144,46 @@ void PSOutput::computeBBox(int width, int height)
PostscriptOptions* pops = (PostscriptOptions*)setupPtr->ops_;
// scale from points to pica
- float pica = 25.4 / 72 *
+ double pica = 25.4 / 72 *
WidthOfScreen(Tk_Screen(graphPtr_->tkwin_)) /
WidthMMOfScreen(Tk_Screen(graphPtr_->tkwin_));
- int hBorder = 2*pops->xPad/pica;
- int vBorder = 2*pops->yPad/pica;
+ double hBorder = 2*pops->xPad/pica;
+ double vBorder = 2*pops->yPad/pica;
int hSize = !pops->landscape ? width : height;
int vSize = !pops->landscape ? height : width;
// If the paper size wasn't specified, set it to the graph size plus the
// paper border.
- int paperWidth = pops->reqPaperWidth > 0 ? pops->reqPaperWidth/pica :
+ double paperWidth = pops->reqPaperWidth > 0 ? pops->reqPaperWidth/pica :
hSize + hBorder;
- int paperHeight = pops->reqPaperHeight > 0 ? pops->reqPaperHeight/pica :
+ double paperHeight = pops->reqPaperHeight > 0 ? pops->reqPaperHeight/pica :
vSize + vBorder;
// Scale the plot size if it's bigger than the paper
- float hScale = (hSize+hBorder) > paperWidth ? 1.0 :
- (float)(paperWidth - hBorder) / hSize;
- float vScale = (vSize + vBorder) > paperHeight ? 1.0 :
- (float)(paperHeight - vBorder) / vSize;
+ double hScale = (hSize+hBorder) > paperWidth ? 1.0 :
+ paperWidth - hBorder / hSize;
+ double vScale = (vSize + vBorder) > paperHeight ? 1.0 :
+ paperHeight - vBorder / vSize;
- float scale = MIN(hScale, vScale);
+ double scale = MIN(hScale, vScale);
if (scale != 1.0) {
- hSize = hSize*scale + 0.5;
- vSize = vSize*scale + 0.5;
+ hSize = (int)(hSize*scale + 0.5);
+ vSize = (int)(vSize*scale + 0.5);
}
- int x = (paperWidth > hSize) && pops->center ?
- (paperWidth - hSize) / 2 : pops->xPad/pica;
- int y = (paperHeight > vSize) && pops->center ?
- (paperHeight - vSize) / 2 : pops->yPad/pica;
+ int x = (int)((paperWidth > hSize) && pops->center ?
+ (paperWidth - hSize) / 2 : pops->xPad/pica);
+ int y = (int)((paperHeight > vSize) && pops->center ?
+ (paperHeight - vSize) / 2 : pops->yPad/pica);
setupPtr->left = x;
setupPtr->bottom = y;
setupPtr->right = x + hSize - 1;
setupPtr->top = y + vSize - 1;
setupPtr->scale = scale;
- setupPtr->paperHeight = paperHeight;
- setupPtr->paperWidth = paperWidth;
+ setupPtr->paperHeight = (int)paperHeight;
+ setupPtr->paperWidth = (int)paperWidth;
}
const char* PSOutput::getValue(int* lengthPtr)
@@ -236,9 +236,9 @@ void PSOutput::fillRectangle(double x, double y, int width, int height)
append("fill\n");
}
-void PSOutput::fillRectangles(XRectangle* rectangles, int nRectangles)
+void PSOutput::fillRectangles(Rectangle* rectangles, int nRectangles)
{
- for (XRectangle *rp = rectangles, *rend = rp + nRectangles; rp < rend; rp++)
+ for (Rectangle *rp = rectangles, *rend = rp + nRectangles; rp < rend; rp++)
fillRectangle((double)rp->x, (double)rp->y, (int)rp->width,(int)rp->height);
}
diff --git a/generic/tkbltGrPSOutput.h b/generic/tkbltGrPSOutput.h
index c54e771..04bb2fd 100644
--- a/generic/tkbltGrPSOutput.h
+++ b/generic/tkbltGrPSOutput.h
@@ -65,7 +65,7 @@ namespace Blt {
void print3DRectangle(Tk_3DBorder, double, double, int, int, int, int);
void fillRectangle(double, double, int, int);
- void fillRectangles(XRectangle*, int);
+ void fillRectangles(Rectangle*, int);
void fill3DRectangle(Tk_3DBorder, double, double, int, int, int, int);
void fillPolygon(Point2d*, int);
diff --git a/generic/tkbltGrPostscript.h b/generic/tkbltGrPostscript.h
index 7ab54a3..a0c35a1 100644
--- a/generic/tkbltGrPostscript.h
+++ b/generic/tkbltGrPostscript.h
@@ -56,11 +56,11 @@ namespace Blt {
void* ops_;
Graph* graphPtr_;
- short int left;
- short int bottom;
- short int right;
- short int top;
- float scale;
+ int left;
+ int bottom;
+ int right;
+ int top;
+ double scale;
int paperHeight;
int paperWidth;
diff --git a/generic/tkbltGrText.C b/generic/tkbltGrText.C
index 65725e7..1bed069 100644
--- a/generic/tkbltGrText.C
+++ b/generic/tkbltGrText.C
@@ -94,13 +94,18 @@ void TextStyle::drawText(Drawable drawable, const char *text, int x, int y)
Point2d rr = rotateText(x, y, w1, h1);
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6)
TkDrawAngledTextLayout(graphPtr_->display_, drawable, gc_, layout,
- rr.x, rr.y, ops->angle, 0, -1);
+ (int)rr.x, (int)rr.y,
+ ops->angle, 0, -1);
#else
Tk_DrawTextLayout(graphPtr_->display_, drawable, gc_, layout,
rr.x, rr.y, 0, -1);
#endif
}
+void TextStyle::drawText(Drawable drawable, const char *text, double x, double y) {
+ return drawText(drawable, text, (int)x, (int)y);
+}
+
void TextStyle::drawText2(Drawable drawable, const char *text,
int x, int y, int* ww, int* hh)
{
@@ -118,10 +123,10 @@ void TextStyle::drawText2(Drawable drawable, const char *text,
Point2d rr = rotateText(x, y, w1, h1);
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6)
TkDrawAngledTextLayout(graphPtr_->display_, drawable, gc_, layout,
- rr.x, rr.y, ops->angle, 0, -1);
+ (int)rr.x, (int)rr.y, ops->angle, 0, -1);
#else
Tk_DrawTextLayout(graphPtr_->display_, drawable, gc_, layout,
- rr.x, rr.y, 0, -1);
+ (int)rr.x, (int)rr.y, 0, -1);
#endif
double angle = fmod(ops->angle, 360.0);
@@ -131,8 +136,8 @@ void TextStyle::drawText2(Drawable drawable, const char *text,
if (angle != 0.0) {
double rotWidth, rotHeight;
graphPtr_->getBoundingBox(w1, h1, angle, &rotWidth, &rotHeight, NULL);
- w1 = rotWidth;
- h1 = rotHeight;
+ w1 = (int)rotWidth;
+ h1 = (int)rotHeight;
}
*ww = w1;
@@ -182,6 +187,10 @@ void TextStyle::printText(PSOutput* psPtr, const char *text, int x, int y)
psPtr->format("] %g %g %s DrawText\n", xx/-2.0, yy/-2.0, justify);
}
+void TextStyle::printText(PSOutput* psPtr, const char *text, double x, double y) {
+ return printText(psPtr, text, (int)x, (int)y);
+}
+
void TextStyle::resetStyle()
{
TextStyleOptions* ops = (TextStyleOptions*)ops_;
diff --git a/generic/tkbltGrText.h b/generic/tkbltGrText.h
index 770e99e..4337e81 100644
--- a/generic/tkbltGrText.h
+++ b/generic/tkbltGrText.h
@@ -68,8 +68,10 @@ namespace Blt {
void* ops() {return ops_;}
void drawText(Drawable, const char*, int, int);
+ void drawText(Drawable, const char*, double, double);
void drawText2(Drawable, const char*, int, int, int*, int*);
void printText(PSOutput*, const char*, int, int);
+ void printText(PSOutput*, const char*, double, double);
void getExtents(const char*, int*, int*);
};
};
diff --git a/generic/tkbltGraph.C b/generic/tkbltGraph.C
index bb1707d..13e0e9a 100644
--- a/generic/tkbltGraph.C
+++ b/generic/tkbltGraph.C
@@ -510,13 +510,13 @@ void Graph::reconfigure()
void Graph::drawMargins(Drawable drawable)
{
GraphOptions* ops = (GraphOptions*)ops_;
- XRectangle rects[4];
+ Rectangle rects[4];
// Draw the four outer rectangles which encompass the plotting
// surface. This clears the surrounding area and clips the plot.
rects[0].x = rects[0].y = rects[3].x = rects[1].x = 0;
- rects[0].width = rects[3].width = (short int)width_;
- rects[0].height = (short int)top_;
+ rects[0].width = rects[3].width = width_;
+ rects[0].height = top_;
rects[3].y = bottom_;
rects[3].height = height_ - bottom_;
rects[2].y = rects[1].y = top_;
@@ -558,7 +558,7 @@ void Graph::printMargins(PSOutput* psPtr)
{
GraphOptions* ops = (GraphOptions*)ops_;
PostscriptOptions* pops = (PostscriptOptions*)postscript_->ops_;
- XRectangle margin[4];
+ Rectangle margin[4];
margin[0].x = margin[0].y = margin[3].x = margin[1].x = 0;
margin[0].width = margin[3].width = width_;
@@ -595,7 +595,7 @@ void Graph::printMargins(PSOutput* psPtr)
if (ops->title) {
psPtr->append("% Graph title\n");
TextStyle ts(this, &ops->titleTextStyle);
- ts.printText(psPtr, ops->title, (double)titleX_, (double)titleY_);
+ ts.printText(psPtr, ops->title, titleX_, titleY_);
}
}
@@ -1426,7 +1426,7 @@ void Graph::drawSegments(Drawable drawable, GC gc,
Segment2d* segments, int nSegments)
{
for (Segment2d *sp = segments, *send = sp + nSegments; sp < send; sp++)
- XDrawLine(display_, drawable, gc, sp->p.x, sp->p.y, sp->q.x, sp->q.y);
+ XDrawLine(display_, drawable, gc, (int)sp->p.x, (int)sp->p.y, (int)sp->q.x, (int)sp->q.y);
}
GC Graph::getPrivateGC(unsigned long gcMask, XGCValues *valuePtr)
diff --git a/generic/tkbltGraph.h b/generic/tkbltGraph.h
index b873823..6f8df01 100644
--- a/generic/tkbltGraph.h
+++ b/generic/tkbltGraph.h
@@ -72,12 +72,12 @@ namespace Blt {
} ClosestSearch;
typedef struct {
- short int width;
- short int height;
- short int axesOffset;
- short int axesTitleLength;
- short int maxTickWidth;
- short int maxTickHeight;
+ int width;
+ int height;
+ int axesOffset;
+ int axesTitleLength;
+ int maxTickWidth;
+ int maxTickHeight;
unsigned int nAxes;
Chain* axes;
int reqSize;
@@ -147,16 +147,16 @@ namespace Blt {
Postscript* postscript_;
int inset_;
- short int titleX_;
- short int titleY_;
- short int titleWidth_;
- short int titleHeight_;
+ int titleX_;
+ int titleY_;
+ int titleWidth_;
+ int titleHeight_;
int width_;
int height_;
- short int left_;
- short int right_;
- short int top_;
- short int bottom_;
+ int left_;
+ int right_;
+ int top_;
+ int bottom_;
Axis* focusPtr_;
int halo_;
GC drawGC_;
@@ -167,8 +167,8 @@ namespace Blt {
double vScale_;
double hScale_;
Pixmap cache_;
- short int cacheWidth_;
- short int cacheHeight_;
+ int cacheWidth_;
+ int cacheHeight_;
protected:
void layoutGraph();
diff --git a/generic/tkbltGraphOp.C b/generic/tkbltGraphOp.C
index 9d4f45b..6588d64 100644
--- a/generic/tkbltGraphOp.C
+++ b/generic/tkbltGraphOp.C
@@ -294,8 +294,8 @@ static int TransformOp(ClientData clientData, Tcl_Interp* interp, int objc,
Point2d point = graphPtr->map2D(x, y, xAxis, yAxis);
Tcl_Obj* listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL);
- Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(point.x));
- Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(point.y));
+ Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj((int)point.x));
+ Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj((int)point.y));
Tcl_SetObjResult(interp, listObjPtr);
return TCL_OK;
diff --git a/generic/tkbltVector.C b/generic/tkbltVector.C
index e6262ec..f355c96 100644
--- a/generic/tkbltVector.C
+++ b/generic/tkbltVector.C
@@ -1241,7 +1241,7 @@ VectorInterpData* Blt::Vec_GetInterpData(Tcl_Interp* interp)
Tcl_InitHashTable(&dataPtr->indexProcTable, TCL_STRING_KEYS);
Vec_InstallMathFunctions(&dataPtr->mathProcTable);
Vec_InstallSpecialIndices(&dataPtr->indexProcTable);
- srand48(time((time_t *) NULL));
+ srand48((long)time((time_t *) NULL));
}
return dataPtr;
}