Thanks.
The program I am trying to write in Qt is a re-write of a DOS program where I transformed my data to fit the screen perameters, so I continued with that mind set and it worked.
With Qt4, there were enough changes in QPainter to make me dig deeper into painter. Without any simple CAD type tutorials, demos or examples where "0,0" is at the lower left, I thought the "setWindow" function would do in painter what I had done in my code.
You suggested translating the "y" coordinates which I think I had in the following code
pRatio = ((double)pX/pY); /// aspect ratio of drawing frame pixels
x1 = (int)(-0.04 * maxX); /// arbitrary 4% left border
y1 = (int)(1.05 * maxY); /// arbitrary 5% top border
xWidth = 1.08 * maxX; /// arbitrary 4% left and right borders
yHeight = 1.1 * maxY; /// arbitrary 5% top and bottom borders
dRatio = (xWidth/yHeight); /// aspect ratio of drawing dimentions
if( pRatio < dRatio ) /// modify the width or height to suit
yHeight *= pRatio;
else
xWidth *= pRatio;
myViewportRect.setRect(0, 0, pX, pY);
myWindowRect.setRect(x1, y1, (int)xWidth, -(int)yHeight);
myClippingRect.setRect(0, (int)maxY, (int)(maxX+1000.0), -(int)(maxY+1000.0));
pRatio = ((double)pX/pY); /// aspect ratio of drawing frame pixels
x1 = (int)(-0.04 * maxX); /// arbitrary 4% left border
y1 = (int)(1.05 * maxY); /// arbitrary 5% top border
xWidth = 1.08 * maxX; /// arbitrary 4% left and right borders
yHeight = 1.1 * maxY; /// arbitrary 5% top and bottom borders
dRatio = (xWidth/yHeight); /// aspect ratio of drawing dimentions
if( pRatio < dRatio ) /// modify the width or height to suit
yHeight *= pRatio;
else
xWidth *= pRatio;
myViewportRect.setRect(0, 0, pX, pY);
myWindowRect.setRect(x1, y1, (int)xWidth, -(int)yHeight);
myClippingRect.setRect(0, (int)maxY, (int)(maxX+1000.0), -(int)(maxY+1000.0));
To copy to clipboard, switch view to plain text mode
which draws the lines properly, including "clipping".
Now why don't the "pen" (except the "setBrush") and "text" functions work?
I can "drawText" on the screen ok before the "setWindow", but not after.
Note: All the data are integers. (1000* inches or 1000*millemeters) to avoid floating point comparison errors.
Bookmarks