Dear Chris,
CM> The Canvas drawing functions are designed to draw in pixel values.
I came to my question because I'm nearly finished two write a small language translator "From HP-Basic to CVI" (details see below).
HP-Basic and other languages, too, offer the 'window' mechanism. That means: A 'window' defines logical ranges to replace the physical x and y ranges (represented in pixels). At a first glance, the CVI statements
SetCtrlAttribute(handle, PANEL_CANVAS, ATTR_XCOORD_AT_ORIGIN, x_origin);
SetCtrlAttribute(handle, PANEL_CANVAS, ATTR_YCOORD_AT_ORIGIN, y_origin);
SetCtrlAttribute(handle, PANEL_CANVAS, ATTR_XSCALING, x_scaling);
SetCtrlAttribute(handle, PANEL_CANVAS, ATTR_YSCALING, y_scaling);
(according to 'userint.h' x_origin, y_origin, x_scaling, y_scaling are DOUBLE)
seems to offer this kind of transformation with Canvas Controls: If you send the above 4 parameters to CVI, CVI is going to automatically shift the origin and the scaling of the axis, but, alas, there is an inconsistency with CVI: when e.g. declaring a scaling multiplier of 1.0 (the default) 100 % of the physical pixels are addressable, but with scaling = 2.0, only 50% are addressable (with 4.0 only 25 % etc). The reason is:
a) in the moment, CVI first truncates the fractional values of a logical (window) point (by use of the 'Point(int, int)' structure)
b) then CVI applies the previously submitted user offsets and multipliers (x_origin, y_origin, x_scaling, y_scaling) to automatically transform the logical points to physical pixels.
Instead of '1st truncate, then multiply' the reverse sequence is correct:
1) first multiply the user's fractional window coordinate values (in DOUBLE) by applying 'window' parameters (x_origin, y_origin, x_scaling, y_scaling - in DOUBLE)
2) then truncate the result (still in DOUBLE) to INTEGER to get the physical pixel coordinates
Could you discuss this with your CVI development staff?
You may say, instead of perfectly windowing canvas controls one could use the graph controls for windowing. However, graph controls involve a lot of internal automatism and prevent the user to pre-determine all details of the final graphical pixels.
Heinz Hoeffken
Some comments to HP-Basic:
In the seventies, Hewlett Packard invented the HP-IB-Bus as a predecessor of the today's NI 488.2 GPIB bus. And in the 70-ies we began to do automated measurements by using HP calculators and HP instruments connected by the HPIB-Bus. Beginning of the eighties, HP-calculators were the state of the art in industry as well as at universities etc. The calculators had a powerful software dialect named HP-Basic (Rocky Mountain Basic) with perfect GPIB implementation. It was IBM and the PC's who caused HP to draw it's HP-Basic calculators from the market. However, in 1988 the American Transera Corp. had adapted the HP-Basic to MS-DOS PC's and sold it as HT-BASIC. Lots of engineers exchanged their HP computers by PC's and continued to use the old well proven HP-Basic measurement programs on PCs with HT-Basic. This was so successful that when MS-Windows came, Hewlett Packard and Transera issued a common "HP-BASIC for Windows" which today is still a little bit on the market.
To summarize:
The factory I'm working with is planning to replace HP-GPIB cards by National Instruments NI-GPIB 488.2 cards and to purchase new LabWindows CVI licenses. We have lots of programs in HP-BASIC to control lots of ATE measurement instruments. I myself am fit in HP-Basic as well as in CVI programming (CVI license owner since 4.5 years), but some of my colleagues still are writing in HP-Basic and are beginners with CVI. That's why I've written a CVI library to allow to type function calls into the CVI editor looking similar to 'HP-Basic syntax'. - The WINDOW statement is one which still makes trouble as discussed above.