X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

6/3/2025

Rethinking the Reliability of Type 1a Supernovae   How do astronomers measure the universe? It all starts with distance. From gauging the size of a galaxy to calculating how fast the universe is expanding, measuring cosmic distances is essential to understanding everything in the sky. For nearby stars, astronomers use... Read More >

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

5/26/2025

Whether you’re new to remote sensing or a seasoned expert, there is no doubt that large language models (LLMs) like OpenAI’s ChatGPT or Google’s Gemini can be incredibly useful in many aspects of research. From exploring the electromagnetic spectrum to creating object detection models using the latest deep learning... Read More >

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

4/28/2025

When every second counts, the ability to process geospatial data rapidly and accurately isn’t just helpful, it’s critical. Geospatial Intelligence (GEOINT) has always played a pivotal role in defense, security, and disaster response. But in high-tempo operations, traditional workflows are no longer fast enough. Analysts are... Read More >

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

4/24/2025

This blog was written by Eli Dwek, Emeritus, NASA Goddard Space Flight Center, Greenbelt, MD and Research Fellow, Center for Astrophysics, Harvard & Smithsonian, Cambridge, MA. It is the fifth blog in a series showcasing our IDL® Fellows program which supports passionate retired IDL users who may need support to continue their work... Read More >

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

2/25/2025

This blog was written in collaboration with Adam O’Connor from Wyvern.   As hyperspectral imaging (HSI) continues to grow in importance, access to high-quality satellite data is key to unlocking new insights in environmental monitoring, agriculture, forestry, mining, security, energy infrastructure management, and more.... Read More >

1345678910Last
8471 Rate this article:
No rating

Using (New) Graphics in an IDL widget program, part II

Anonym

Last week, I demonstrated how to set up a widget interface that embeds an IDL 8 (aka New) Graphics (NG) window with the WIDGET_WINDOW function. This week, let’s see how event handling works in this program. (Get the full program here.) Start with the event handler for the slider widget:

 pro widget_window_ex1_index_event, event compile_opt idl2 ; Get the state variable. widget_control, event.top, get_uvalue=w state = w.uvalue ; Store the new image index and update the display. state['index'] = event.value widget_window_ex1_display, w end 

This event handler follows the standard IDL widget programming model: it’s a procedure that accepts one parameter, the event structure, from XMANAGER. Recall that I chose to store the NG window reference in the user value of the top-level base, with the actual state variable for the program in the user value of this NG window. This is nonstandard, but it gives one way to pass state information to both the widget event handler and the NG event handler. To unpack the state variable, we reverse these steps in the event handler. In the last two statements, we get the value of the slider from the widget system and store it in the state variable, then call the helper _DISPLAY routine to refresh the window. We’ll look at this helper routine shortly, but let’s next review the event handler for mouse wheel events in the NG window:

 function widget_window_ex1_mouse_wheel_event, w, x, y, d, k compile_opt idl2 ; Get the state variable. state = w.uvalue ; Update the image index based on the value of "d". Also make ; sure the image index stays within [0, n_images-1]. state['index'] += d state['index'] = (state['index'] > 0) < (state['n_images']-1) ; Update the display with the new image. widget_window_ex1_display, w ; Update the value of the slider. widget_control, state['index slider'], set_value=state['index'] ; Cancel the default NG zoom behavior of the scroll wheel. return, 0 end 

Note that this NG event handler is a function. It accepts five parameters: w is the NG window reference, x and y give the event location in device coordinates, d gives the magnitude and direction (positive or negative) of the scroll wheel movement, while k stores the value of any modifier keys used. For more information on these parameters, as well as those for other types of NG window events, please see the entries for WIDGET_WINDOW and “Creating Mouse Event Functions” in the IDL Help. We start this event handler by unpacking the state variable from the NG window reference. Next, we increment or decrement the index of the image by adding the value of the scroll wheel parameter d. This value is usually on [-1,1], but I recall once getting a value of -8 (try adding a PRINT statement to see the values of d). Ensure that the index is in the range [0,56] to avoid a subscripting error. The NG window can then be updated with the newly indexed image from the stack with the helper _DISPLAY routine. The slider widget also needs to be synced up with the new image index value. Last, NG event handlers are expected to return a value of 1, indicating that the default event handling action (for the scroll wheel, this is zooming) should be performed, or 0, which short-circuits the default handling and returns control to the standard widget event loop. I chose here to turn off the default zoom action. Finally, the helper _DISPLAY routine:

 pro widget_window_ex1_display, w compile_opt idl2 state = w.uvalue w['head display'].setdata, (state['image'])[*,*,state['index']] end 

This routine isn’t an event handler, but it helps in the event handling process. I chose to write it as a procedure and accept the NG window reference (which includes the state variable) as a parameter. Here’s where the NG NAME property is handy: the expression w['head display'] is the NG reference returned by IMAGE in the widget creation routine (where it’s called g). Here, the SetData method, introduced in IDL 8.1, is used to update the data used by IMAGE to the current image in the stack. The display in the NG window is automatically updated. Here’s an animated GIF (made with IDL’s WRITE_GIF procedure) showing the program in action!

The widget program WIDGET_WINDOW_EX1 in action!

(I've been enjoying the recent resurgence of animated GIFs in simple scientific visualizations, like here – check out the IDL Direct Graphics!)

Please login or register to post comments.