[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keyword precedence



Mark Hadfield wrote:
> 
> [...]  for each element foo add a single keyword,
> foo_properties, thus:
> 
> pro my_visualisation $
>     , VIEW_PROPERTIES=view_properties $
>     , XAXIS_PROPERTIES=xaxis_properties $
>     , YAXIS_PROPERTIES=yaxis_properties $
>     , SURFACE_PROPERTIES=surface_properties $
>     , WINDOW_PROPERTIES=window_properties
> 
>     theview = new_view(UNITS=2, DIMENSIONS=[10,10], _EXTRA=view_properties)
>     thexaxis = new_axis(DIRECTION=0, TICKFORMAT=...,
> _EXTRA=xaxis_properties)
>     theyaxis = new_axis(DIRECTION=1, TICKFORMAT=...,
> _EXTRA=yaxis_properties)
>     ; Add the axes to a model & add that to the view
>     ; Get data
>     thesurface = new_surface(STYLE=2, DATAX=..., _EXTRA=surface_properties)
>     ; add the surface to the model
>     new_window, GRAPHICS_TREE=theview, RETAIN=2, _EXTRA=window_properties
> end
> 
> Now to control (say) the X axis the caller just sets xaxis_properties equal
> to a structure containing the appropriate keyword:value pairs, e.g.:
> 
> my_visualisation, XAXIS_PROPERTIES={notext:1, minor:0}
> 
> Now this approach obviously relies on the "_properties" structures
> overriding the defaults. When I first tried this I found that the
> xaxis_properties keyword was not working and that this was because I had
> happened to use inheritance by reference in new_axis. The rest (as they say)
> is history...

   If you follow this approach, you might almost as well pass the
structure explicitely instead of relying on the _extra passing
mechanism. Things like this prompted me a while ago to write my
little ChkStru routine, where you test (a) if the thing you test
is a structure, and (b) if it contains what you are looking for.
An example for setting axis properties could look like:
    IF ChkStru(xaxis_properties, 'DIRECTION') THEN
thexaxis->SetProperty,  $
       direction=xaxis_properties.direction
    IF ...

  But I realize, this may get a bit lengthy from time to time ;-)

Thanks for the thoughtful discussion,

Martin

-- 
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
[[ Dr. Martin Schultz   Max-Planck-Institut fuer Meteorologie   
[[
[[                      Bundesstr. 55, 20146 Hamburg            
[[
[[                      phone: +49 40 41173-308                 
[[
[[                      fax:   +49 40 41173-298                 
[[
[[ martin.schultz@dkrz.de                                       
[[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[