Below is a listing of changes I have made to IDLex and related code. I renamed the changed routines to "PCSex". (The initials of my full name are "PCS".) Notable among these changes is the addition and use of the QUICK keyword, which is used to quickly recalculate measurements for normalizing graphics content. Such QUICK recalculations, sprinkled throughout these code modifications, help make the parts of this code that implement normalization and STATIONARY functionality cleaner and a little bit easier to understand (I hope). Also of note is that methods intended for non-public use are indicated with a comment (i.e. "internal"). Though that may not seem like a big deal, I think it makes the code easier to read.
Almost all of the modifications were made with respect to IDL 5.5 on my WindowsME PC and were submited to RSI in 2002 (incident ID 126783). I have since upgraded to WindowsXP and IDL 6.0, and have made perhaps one or two more tweaks to the code. Those tweaks are included here. I have not tested on other hardware or operating systems.
Thanks to Dick Jackson for his suggestions and input.
Sincerely,
Paul C. Sorenson
www.paulsorenson.com
FILENAME: pcsexinscribingview__define.pro
METHOD: PCSexInscribingView::init
Added code to perform more robust cleanup in the event of an error.
Added keywords and supporting code so that properties specific to
this class can now be set at init time.
Added code to check self's debug status and stop IDL at errant code
(ON_ERROR, 0) if debug is set.
METHOD: PCSexInscribingView::SetProperty
Fixed spelling: from "do_aspec" to "do_aspect." The improper spelling
was causing an error to be thrown when the user tried to set or un-set
DO_ASPECT via the SetProperty method.
METHOD: PCSexInscribingView::GetProperty
Added this missing routine to get ISOTROPIC and DO_ASPECT properties.
---------------------------------------------------------------------------
FILENAME: pcsexobjview__define.pro
Commented methods intended for non-public use as "internal."
Added code to check self's debug status and stop IDL at errant code
(ON_ERROR, 0) if debug is set. (Debug status is set by calling obj_new
with the debug keyword set.) Previously this was only implemented in
some parts of the code, now it is implemented throughout.
Changed the name of the method RakeHeap to SpecificCleanup. This method
cleans up heap variables that are specific to this class. Prior versions
of IDLex code used two different names for this kind of method,
CleanupNonInheritedMembers and RakeHeap.
Made the SCALE property of this class scalar. Previously, it was a three
element vector for unequal scaling in x, y, and z. Having a three
element SCALE, however, was more confusing than necessary, as the user
can simply utilize a model when such unequal scaling is desired.
Added an additional PCSexObjView__example showing this class' ability to
automatically adjust axes.
METHOD: PCSexObjview::Normalize
Improved speed of algorithm. In certain cases this method was
traversing the graphics tree more than once. Now such behavior is
avoided by using CalcRanges' QUICK keyword. In addition, the graphics
tree is now only traversed if necessary.
Added a SCALE keyword which affects the overall result equally in all
three dimensions.
Fixed problem where outlying stationary objects corrupted normalization.
See figure 1 and figure 2. Figure 1 shows example data prior
to the fix. Figure 2 shows the same data after the fix. Here is
the example code I used to generate the figures:
pro make_figure
oWindow = obj_new('IDLgrWindow', retain=2, dimensions=[300,300])
oOrb1 = obj_new('Orb', color=[0,255,0])
oOrb2 = obj_new('Orb', color=[255,0,0])
oOrb2->Translate, 0, -10, 0
oView = obj_new('PCSexObjView')
oView->Rotate, [0,0,1], -225
oView->Add, oOrb2
oView->Add, oOrb1, /stationary
oView->Normalize, oWindow
oWindow->Draw, oView
end
METHOD: PCSexObjview::CalcRanges
Added QUICK keyword and other modifications for use by the normalize
method.
METHOD: PCSexObjview::GetProperty
Added the ability to get X_CRANGE, Y_CRANGE, and Z_CRANGE properties.
These properties are analogous to IDL Direct Graphics' !x.crange,
!y.crange, and !z.crange respectively. These properties are used by the
PCSexPlot3DviewWid class when updating its menus.
---------------------------------------------------------------------------
FILENAME: pcsexobjviewwid__define.pro
Commented methods intended for non-public use as "internal."
Added code to check self's debug status and stop IDL at errant code
(ON_ERROR, 0) if debug is set. (Debug status is set by calling obj_new
with the debug keyword set.) Previously this was only implemented in
some parts of the code, now it is implemented throughout.
Changed the name of method CleanupNoninheritedMembers to SpecificCleanup.
Added an example routine, PCSexObjViewWid__example, showing a simple use
of this class of widget.
METHOD: PCSexObjviewWid::SetProperty
Refactored this method so that most properties can be set regardless of
whether this object's widgets have been created.
METHOD: PCSexObjViewWid::init
Added INITIAL_X_RANGE, INITIAL_Y_RANGE, INITIAL_Z_RANGE keywords.
These ranges are in data space.
METHOD: PCSexObjViewWid::ReCreateWidgets
Added this method for use in restoring objects of this class. When an
object of this class is restored, it comes back to life exactly as the
user left it (x size, y size, background color, etc.) when it was saved.
---------------------------------------------------------------------------
FILENAME: pcsexwidget__define.pro
Refactored widget creation code into methods
PCSexWidget::ReCreateWidgets (for use in restoring) and
PCSexWidget::CreateSpecificWidgets (for internal use).
---------------------------------------------------------------------------
FILENAME: pcsexviewgroup__define.pro
METHOD: PCSexViewGroup::init
Fixed error handling code so that error messages are output to the
standard error stream (file unit -2).
---------------------------------------------------------------------------
FILENAME: pcsexvolviewwid__define.pro
Fixed an error in one of the comments.
---------------------------------------------------------------------------
FILENAME: pcsexvolview__define.pro
METHOD: PCSexVolView::Normalize
Added _EXTRA keyword to accommodate keyword SCALE (which is passed
through to the parent version of this method).
---------------------------------------------------------------------------
FILENAME: xplot3d.pro
Refactored most of this routine into two new classes: PCSexPlot3Dview
and PCSexPlot3DviewWid. These classes serve to separate interface
(PCSexPlot3DviewWid) from implementation (PCSexPlot3Dview), and thus
make the code more suitable for reuse in both IDL and external
applications.
Added DEBUG keyword and functionality. This allows the user to see the
exact line of code where an error occurs if he or she so desires.
Removed common block. The IDL 5.5 version of xplot3d relied on a common
block for its overplotting functionality. Now there are no common blocks
in xplot3d.pro.
Added "Full Reset" menu button. This button resets axis ranges to
accommodate curves that may have been OVERPLOTted by the user. See
figure 3 and figure 4. Figure 3 shows an overplotted graph
before "Full Reset" has been clicked. Figure 4 shows the graph after
"Full Reset" has been clicked.
pro example
;
;Purpose: provide an example for the use of xplot3d's Full Reset menu
;button.
;
ramp = findgen(1000) / 999.
x = sin(ramp * 45) * ramp
y = cos(ramp * 45) * ramp
z = ramp
xplot3d, x, y, z, $
color=[0, 255, 0], $
thick=2, $
background=[80, 80, 80]
xplot3d, x+2, y, z, $
color=[255, 0, 255], $
thick=2, $
/overplot
;
;Click on the "View|Full Reset" menu button to see the effect of this
;feature. Axes ranges will be reset to accommodate both the green and
;magenta curves.
;
end
Fixed crash-to-IDL-prompt bug. In IDL 5.5, when the user clicked on
xplot3d's "Print" menu button, the program would crash to the IDL prompt
with the error message: "Attempt to call undefined method:
'IDLEXINSCRIBINGVIEW::VIEWPORTDIMENSIONS'."
---------------------------------------------------------------------------
FILENAME: pcsexplot3dviewwid__define.pro
Added this new file. Objects of this class are GUIs that can be saved
and then restored with the exact same size, appearance, and state with
which they were saved. To bring back the GUI, use
PCSexPlot3DviewWid::ReCreateWidgets after restoring.
As with its parent, this class allows its menu and toolbar to be broken
out for display elsewhere in a client application if desired. See
figure 9 for one possible configuration.
Changed menu button labels under "2D Projections." Where the old buttons
said "XY Plane," "XZ Plane," and "YZ Plane," the new buttons say "X =
1.000," "Y = 1.000," and "Z = 0.000." The actual numbers that appear in
these button labels are derived from the data. See figure 5 and
figure 6. Figure 5 shows what these buttons looked like before
this modification. Figure 6 shows the buttons after this
modification.
See procedure PCSexPlot3dViewWid__example for an example of how this
class can be used.
This class is deployed by xplot3d.pro.
---------------------------------------------------------------------------
FILENAME: pcsexplot3dview__define.pro
Added this new file. Objects of this class are PCSexObjViews extended to
provide axes and other features for 3D plots. Any atomic graphics object
can be added to a view of this class. For example, Figure 9 shows a
view with a red orb and a green polyline. See procedure
PCSexPlot3dView__example for a code example of how this class can be used.
Included tick marks on the "simple axes." See figure 6.
Included logic to correctly handle both ISOTROPIC and nonISOTROPIC plots,
even in the extreme case where data is flat in one or more dimensions.
See figure 7 and figure 8. Here is the code I used to generate those
figures:
oWindow = obj_new("IDLgrWindow", retain=2)
oPolygon = obj_new("IDLgrPolygon", $
[10,10,10], $
[0,1,0], $
[0,1,1], $
color=[0,0,255] $
)
oView = obj_new("PCSexPlot3dView", isotropic=0)
oView->Rotate, [0,0,1], 30
oView->Rotate, [1,0,0], -60
oView->Add, [oPolygon]
oView->Normalize, oWindow, /adjust_axes
oWindow->Draw, oView
oWindow = obj_new("IDLgrWindow", retain=2, location=[0,500])
oView = obj_new("PCSexPlot3dView", isotropic=1)
oView->Rotate, [0,0,1], 30
oView->Rotate, [1,0,0], -60
oView->Add, [oPolygon],/alias
oView->Normalize, oWindow, /adjust_axes
oWindow->Draw, oView
This class is deployed by xplot3d.pro.
---------------------------------------------------------------------------
FILENAME: xvolume.pro
Fixed keyword REPLACE functionality to HIDE the new volume if
appropriate. This fix facilitates the creation of isosurface animations
that look like:
http://www-fpc.stanford.edu/~bewley/movies/intro_25.25.html . Here is a
simple example:
pro example, dd
d = dd
sz = size(d, /dimensions)
for i=0,sz[0]-1 do begin
xvolume, d, /replace
filename = 'img' + strcompress(i, /remove_all) + '.bmp'
; xvolume_write_image, filename, 'bmp' ;you can feed these to
;xinteranimate
d = shift(d, 1, 0, 0)
end
end
IDL> d=randomu(s,5,5,5)
IDL> d=bytscl(congrid(d,50,25,25))
IDL> xvolume,d ;interactively hide volume, show isosurface.
IDL> example,d