The following enhancements have been made to IDL's visualization functionality for the 6.0 release:
IDL 6.0 incorporates the FreeType Library for improved rendering of Object Graphics fonts. Previously, characters in an IDLgrText object were rendered by tessellating each glyph outline into a set of small triangles. IDL 6.0 renders an entire IDLgrText string as a high quality bitmap, which is texture mapped onto a single polygon. This technique allows for clearer characters at any size, easier manipulations, background colors, kerning, and blending. For information on the FreeType Project, visit http://www.freetype.org.
The properties to IDLgrText related to this new font rendering are:
| Note |
For more details on these properties, see IDLgrText.
The following example routines show how to use the new font properties to the IDLgrText object. While running these routines, you can proceed to the next display by quitting (File ® Quit) out of the current XOBJVIEW display.
This first example compares simple font rendering tasks in IDL 6.0 and previous versions of IDL.
PRO ExCompareSimpleFonts
; Create previous version text object and IDL 6.0 text
; object (with kerning applied).
oText1 = OBJ_NEW('IDLgrText', 'IDL 5.6', $
RENDER_METHOD = 1, LOCATIONS = [0, 0.05, 0])
oText2 = OBJ_NEW('IDLgrText', 'IDL 6.0', $
LOCATIONS = [0, -0.05, 0], /KERNING)
; Show the text objects.
oModel = OBJ_NEW('IDLgrModel')
oModel -> Add, oText1
oModel -> Add, oText2
XOBJVIEW, oModel, /BLOCK
; Put a polygon behind the text and give the IDL 6.0 text
; a background color.
oText2 -> SetProperty, FILL_BACKGROUND = 1, $
FILL_COLOR = [0, 255, 0]
oPoly = OBJ_NEW('IDLgrPolygon', [-0.1, 0.1, 0.1, -0.1], $
[0.1, 0.1, -0.1, -0.1], [0., 0., 0., 0.], $
COLOR = [255, 0, 0], /DEPTH_OFFSET)
; Show the polygon and updated text objects.
oModel -> Add, oPoly
XOBJVIEW, oModel, /BLOCK
; Make the text semi-transparent to let the polygon
; show through and display the results.
oText2 -> SetProperty, ALPHA_CHANNEL = 0.5
XOBJVIEW, oModel, /BLOCK
; Cleanup.
OBJ_DESTROY, [oModel]
END
The following figure shows the results of this example:
The following example is more involved than the previous one. It shows how to use IDL 6.0's font rendering improvements to clarify cluttered axis and data labels.
PRO ExFreeTypeAxes
; Create data.
angle = 2.*!PI*(0.5 - (FINDGEN(37)/36.))
amplitude = 5*SIN(angle)
; Create a model to contain the plots, axes, labels, and titles
; to that model.
oModel = OBJ_NEW('IDLgrModel')
; Create plots and add them to the model.
oPlots = OBJARR(5)
FOR i = 0, 4 DO BEGIN
oPlots[i] = OBJ_NEW('IDLgrPlot', angle, $
(amplitude*(1. - (i*0.05))))
ENDFOR
oPlots[0] -> GetProperty, XRANGE = xRange, YRANGE = yRange
oModel -> Add, oPlots
; Create axes and add them to the model.
oXAxis = OBJ_NEW('IDLgrAxis', 0, $
RANGE = xRange, /EXACT)
oModel -> Add, oXAxis
oYAxis = OBJ_NEW('IDLgrAxis', 1, $
RANGE = yRange, /EXACT)
oModel -> Add, oYAxis
; Create labels and add them to the model.
xLabel = 2.*!PI*(0.5 - (FINDGEN(20)/19.))
yLabel = 5*SIN(xLabel)
oLabels = OBJARR(N_ELEMENTS(xLabel))
FOR i = 0, (N_ELEMENTS(oLabels) - 1) DO BEGIN
oLabels[i] = OBJ_NEW('IDLgrText', $
STRTRIM(xLabel[i],2), $
LOCATION = [xLabel[i], yLabel[i]], $
CHAR_DIMENSIONS = [0.3, 0.3], $
ALIGNMENT = 0.5)
ENDFOR
oModel -> Add, oLabels
; Create titles and add them to the model.
oXTitle = OBJ_NEW('IDLgrText', $
'Alpha = Angle (Radians)', LOCATION = [0, yRange[0]], $
ALIGNMENT = 0.5, CHAR_DIMENSIONS = [0.5, 0.5], $
ZCOORD_CONV = [0.1, 1])
oModel -> Add, oXTitle
oYTitle = OBJ_NEW('IDLgrText', $
'Epsilon = Amplitude (Centimeters)', $
LOCATION = [xRange[0], 0], ALIGNMENT = 0.5, $
CHAR_DIMENSIONS = [0.5,0.5], BASELINE = [0, 1], $
UPDIR = [-1, 0], ZCOORD_CONV = [0.1, 1])
oModel -> Add, oYTitle
oTitle = OBJ_NEW('IDLgrText', 'SINE WAVE', $
ALIGNMENT = 0.5, VERTICAL_ALIGNMENT = -1., $
LOCATIONS = [MEAN(xRange), yRange[1]], $
CHAR_DIMENSIONS = [0.7, 0.7])
oModel -> Add, oTitle
; Display the model.
XOBJVIEW, oModel, /BLOCK, SCALE = 0.9, $
TITLE = 'Original Display'
; Make the axis titles translucent.
oXTitle -> SetProperty, /FILL_BACKGROUND, $
FILL_COLOR = [230, 230, 230], ALPHA_CHANNEL = 0.5
oYTitle -> SetProperty, /FILL_BACKGROUND, $
FILL_COLOR = [230, 230, 230], ALPHA_CHANNEL = 0.5
; Make the labels translucent.
FOR i = 0, (N_ELEMENTS(oLabels) - 1) DO BEGIN
oLabels[i] -> SetProperty, ALPHA_CHANNEL = 0.6
ENDFOR
; Display the modified model.
XOBJVIEW, oModel, /BLOCK, SCALE = 0.9, $
TITLE = 'Improved Display'
; Cleanup object references.
OBJ_DESTROY, oModel
END
In graphics rendering, the depth buffer is an array of depth values maintained by a graphics device, one value per pixel, to record the depth of primitives rendered at each pixel. It is usually used to prevent the drawing of objects located behind other objects that have already been drawn in order to generate a visually correct scene. In IDL, smaller depth values are closer to the viewer.
New properties to graphic objects in IDL 6.0 provide more control over how Object Graphics primitives are affected by the depth buffer. You can now control which primitives may be rejected from rendering by the depth buffer, how the primitives are rejected, and which primitives may update the depth buffer.
Control of the depth buffer is achieved through a test function or by completely disabling the buffer. The depth test function is a logical comparison function used by the graphics device to determine if a pixel should be drawn on the screen. This decision is based on the depth value currently stored in the depth buffer and the depth of the primitive at that pixel location.
The test function is applied to each pixel of an object. A pixel of the object is drawn if the object's depth at that pixel passes the test function set for that object. If the pixel passes the depth test, the depth buffer value for that pixel is also updated to the pixel's depth value.
The possible test functions are:
The IDL default is LESS. Commonly used values are LESS and LESS OR EQUAL, which allow primitives closer to the viewer to be drawn.
Disabling the depth test function allows all primitives to be drawn on the screen without testing their depth against the values in the depth buffer. When the depth test is disabled, the graphics device effectively uses the painter's algorithm to update the screen. That is, the last item drawn at a location is the item that remains visible. The depth test function of ALWAYS produces the same result as disabling the depth test.
Moreover, you can disable updating the depth buffer. Disabling depth buffer writing prevents the updating of depth information as primitives are drawn to the frame buffer. Such primitives are unprotected in the sense that any other primitive drawn later at that location will draw over it as if it were not there.
Most atomic graphics objects now have the following new properties related to the depth buffer:
For more details on these properties, see New IDL Object Properties.