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!



Easily Share Workflows With the Analytics Repository

Easily Share Workflows With the Analytics Repository

10/27/2025

With the recent release of ENVI® 6.2 and the Analytics Repository, it’s now easier than ever to create and share image processing workflows across your organization. With that in mind, we wrote this blog to: Introduce the Analytics Repository Describe how you can use ENVI’s interactive workflows to... Read More >

Deploy, Share, Repeat: AI Meets the Analytics Repository

Deploy, Share, Repeat: AI Meets the Analytics Repository

10/13/2025

The upcoming release of ENVI® Deep Learning 4.0 makes it easier than ever to import, deploy, and share AI models, including industry-standard ONNX models, using the integrated Analytics Repository. Whether you're building deep learning models in PyTorch, TensorFlow, or using ENVI’s native model creation tools, ENVI... Read More >

Blazing a trail: SaraniaSat-led Team Shapes the Future of Space-Based Analytics

Blazing a trail: SaraniaSat-led Team Shapes the Future of Space-Based Analytics

10/13/2025

On July 24, 2025, a unique international partnership of SaraniaSat, NV5 Geospatial Software, BruhnBruhn Innovation (BBI), Netnod, and Hewlett Packard Enterprise (HPE) achieved something unprecedented: a true demonstration of cloud-native computing onboard the International Space Station (ISS) (Fig. 1). Figure 1. Hewlett... Read More >

NV5 at ESA’s Living Planet Symposium 2025

NV5 at ESA’s Living Planet Symposium 2025

9/16/2025

We recently presented three cutting-edge research posters at the ESA Living Planet Symposium 2025 in Vienna, showcasing how NV5 technology and the ENVI® Ecosystem support innovation across ocean monitoring, mineral exploration, and disaster management. Explore each topic below and access the full posters to learn... Read More >

Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

9/8/2025

Geohazards such as slope instability, erosion, settlement, or seepage pose ongoing risks to critical infrastructure. Roads, railways, pipelines, and utility corridors are especially vulnerable to these natural and human-influenced processes, which can evolve silently until sudden failure occurs. Traditional ground surveys provide only periodic... Read More >

1345678910Last
«November 2025»
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
8895 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.