Setting Graphics Coordinates

The coordinate-setting routines control where graphics can appear on the screen. Visual Fortran graphics routines recognize the following sets of coordinates:

Unless you change it, the viewport-coordinate system is identical to the physical-coordinate system. The physical origin (0, 0) is always in the upper-left corner of the display.

For QuickWin, display means a child window's client area, not the actual monitor screen (unless you go to Full Screen mode). The x-axis extends in the positive direction left to right, while the y-axis extends in the positive direction top to bottom. The default viewport has the dimensions of the selected mode. In a QuickWin application, you can draw outside of the child window's current client area. If you then make the child window bigger, you will see what was previously outside the frame.

You can also use coordinate routines to convert between physical-, viewport-, and window-coordinate systems. (For more detailed information on coordinate systems, see Drawing Graphics Elements.)

You can set the pixel dimensions of the x- and y-axes with SETWINDOWCONFIG. You can access these values through the wc%numxpixels and wc%numypixels values returned by GETWINDOWCONFIG. Similarly, GETWINDOWCONFIG also returns the range of colors available in the current mode through the wc%numcolors value.

You can also define the graphics area with SETCLIPRGN and SETVIEWPORT. Both of these functions define a subset of the available window area for graphics output. SETCLIPRGN does not change the viewport coordinates, but merely masks part of the screen. SETVIEWPORT resets the viewport bounds to the limits you give it and sets the origin to the upper-left corner of this region.

The origin of the viewport-coordinate system can be moved to a new position relative to the physical origin with SETVIEWORG. Regardless of the viewport coordinates, however, you can always locate the current graphics output position with GETCURRENTPOSITION and GETCURRENTPOSITION_W. (For more detailed information on viewports and clipping regions, see Drawing Graphics Elements.)

Using the window-coordinate system, you can easily scale any set of data to fit on the screen. You define any range of coordinates (such as 0 to 5000) that works well for your data as the range for the window-coordinate axes. By telling the program that you want the window-coordinate system to fit in a particular area on the screen (map to a particular set of viewport coordinates), you can scale a chart or drawing to any size you want. SETWINDOW defines a window-coordinate system bounded by the specified values. See the Visual Fortran Sample SINE.F90 in the ...\DF98\SAMPLES\TUTORIAL folder for an example of this technique.

GETPHYSCOORD converts viewport coordinates to physical coordinates, and GETVIEWCOORD translates from physical coordinates to viewport coordinates. Similarly, GETVIEWCOORD_W converts window coordinates to viewport coordinates, and GETWINDOWCOORD converts viewport coordinates to window coordinates.

For more information: