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!



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 >

Geo Sessions 2025: Geospatial Vision Beyond the Map

Geo Sessions 2025: Geospatial Vision Beyond the Map

8/5/2025

Lidar, SAR, and Spectral: Geospatial Innovation on the Horizon Last year, Geo Sessions brought together over 5,300 registrants from 159 countries, with attendees representing education, government agencies, consulting, and top geospatial companies like Esri, NOAA, Airbus, Planet, and USGS. At this year's Geo Sessions, NV5 is... Read More >

1345678910Last
«October 2025»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
18862 Rate this article:
3.3

ENVI Extensions: Getting notifications from ENVI ROIs

Anonym

A recent project I worked on required an ENVI extension to respond ROI changes made in the ENVI Layer Manager.   Fortunately, ENVI provides a mechanism that allows an object to do this.  First, the object must be added to the list of observers for each ROI layer.  The following command provides access to these layers:

IDLcf$Get , /INCLUDE_VIS_CHILDREN, VIS_LAYERS=oVisLayers

The variable oVisLayers will contain all visible layers present in the ENVI display.  To get only the ROIs, loop through its contents looking for any instances of IDLcfVisROINative.  When one is encountered the object can be added to the ROI layer’s list of observers using the following:

void = oVisLayers[i]-> AddObserver (self)

Now that the object has been added to the list of observers an OnNotify method must be added.  Any notifications from the ROI layers will be sent to this method.

function my_class ::OnNotify, oSubject, strMsg, strArg

The input parameters are:\

  • oSubject – A reference to the ENVI object sending the notification
  • strMsg – A string containing the name of the notification (e.g. SETPROPERTY)
  • strArg – A string containing additional notification information (e.g. HIDE)

Here is a stand-alone example that demonstrates setting up an object to receive and act on notifications from ROIs in the ENVI Layer Manager:

;##############################################################################

; This example demonstrates how to get notifications from ENVI when changes are

; made to ROIs in the Layer Manager.

;##############################################################################

;------------------------------------------------------------------------------

;+

; Event handler used by XMANAGER

;

; :Params:

;   sEvent: in, required, type="struct"

;     An IDL event structure

;-

pro roi_demo_event, sEvent

  widget_control, sEvent.top, GET_UVALUE=oRoiDemo

  oRoiDemo->Event, sEvent

end

;------------------------------------------------------------------------------

;+

; Checks ENVI for any ROIs.  DIsplays all of the ROIs found in the message

; text box.

;

; :Keywords:

;   PREFIX: in, optional, type="string"

;     A string or string array of text to be added to the beginning of the ROI

;     message.

;-

pro roi_demo::CheckROIs, $

  PREFIX=prefix

  compile_opt idl2, logical_predicate

  IDLcf$Get, /INCLUDE_VIS_CHILDREN, VIS_LAYERS=oVisLayers

  name = []

  for i = 0, n_elements(oVisLayers)-1 do begin

    if isa(oVisLayers[i], 'IDLcfVisROINative') then begin

      void = oVisLayers[i]->AddObserver(self)

      oROI = oVIsLayers[i]->GetParameter('ROI')

      if obj_valid(oROI) then begin

        name = [name, oROI.name]

      endif

    endif

  endfor

  if (n_elements(prefix) EQ 0) then prefix = 'ROIs found:'

  str = [prefix,(n_elements(name) GT 0) ? name : 'No ROIs found']

  widget_control, widget_info(self.tlb, FIND_BY_UNAME='text_message'), SET_VALUE=str

end

;------------------------------------------------------------------------------

;+

; Creates a dialog for displaying information regarding the ENVI ROIs

;-

pro roi_demo::Dialog

  compile_opt idl2, logical_predicate

  e = envi(/CURRENT)

  self.tlb = widget_base(/COLUMN, /FLOATING, GROUP_LEADER=e.widget_id, $

    TITLE='ENVI ROI Demo')

  xSize = 100

  wLabel = widget_label(self.tlb, /ALIGN_LEFT, VALUE='Notification Information')

  wText = widget_text(self.tlb, UNAME='text_params', XSIZE=xSize, YSIZE=3)

  wLabel = widget_label(self.tlb, /ALIGN_LEFT, VALUE='ROI Information')

  wText = widget_text(self.tlb, UNAME='text_message', XSIZE=50, YSIZE=10)

  wBase = widget_base(self.tlb, /ALIGN_RIGHT, /ROW)

  wButton = widget_button(wBase, UNAME='check_roi', VALUE='Check ROIs')

  widget_control, self.tlb, /REALIZE, SET_UVALUE=self

  self->CheckROIs

  xmanager, 'roi_demo', self.tlb, /NO_BLOCK

end

;------------------------------------------------------------------------------

;+

; Event handler for the ROI demo's dialog

;

; :Params:

;   sEvent: in, required, type="struct"

;     An IDL event structure

;-

pro roi_demo::Event, sEvent

  compile_opt idl2, logical_predicate

  case widget_info(sEvent.id, /UNAME) of

    'check_roi': self->CheckROIs

    else: print, widget_info(sEvent.id, /UNAME)

  endcase

end

;------------------------------------------------------------------------------

;+

; Lifecycle method for initializing the object

;

; :Returns:

;   1 if the object initializes successfully and 0 otherwise

;-

function roi_demo::Init, $

  _REF_EXTRA=refExtra

  compile_opt idl2, logical_predicate

  if (~self->IDLmiObserver::Init(_EXTRA=refextra)) then begin

    print, 'Failed to initialize IDLmiObserver'

    return, 0

  endif

  return, 1

end

;------------------------------------------------------------------------------

;+

; This method is for receiving notifications from the notifiers for which this

; class is an observer.

;

; :Returns:

;   1

;

; :Params:

;   oSubject: in, required, type="objref"

;     The ENVI object that is sending the notifications

;   strMsg: in, required, type="string"

;     The notification string (e.g. SETPROPERTY)

;   strArg: in, required, type="string"

;     A string containing additional notification information (e.g. HIDE)

;-

function roi_demo::OnNotify, oSubject, strMsg, strArg

  compile_opt idl2, logical_predicate

  oSubject->GetProperty, NAME=name

  help, oSubject, OUTPUT=strHelp

  widget_control, widget_info(self.tlb, FIND_BY_UNAME='text_params'), $

    SET_VALUE=[strHelp, 'STRMSG: '+strMsg, 'STRARG: '+strArg]

  str = ''

  case strupcase(strMsg) of

    'ADDITEMS': begin

      str = ['Adding a new ROI','Press Check ROIs when finished']

    end

    'REMOVEITEMS': begin

      self->CheckROIs, PREFIX=['ROI has been removed','Remaining ROIs:']

      return, 1

    end

    'ROI_DEFINITION_CHANGE': begin

      str = name+' has been updated'

    end

    'SETPROPERTY': begin

      case strupcase(strArg) of

        'COLOR': begin

          oROI = oSubject->GetParameter('ROI')

          oROI->GetProperty, COLOR=color

          str = name+' color changed to '+strjoin(strtrim(fix(color),2),',')

        end

        'HIDE': begin

          oSubject->GetProperty, HIDE=hide

          str = name+' has been '+(hide ? 'hidden' : 'shown')

        end

        else:

      endcase

    end

    else: print, 'MESSAGE: '+strMsg

  endcase

  wText = widget_info(self.tlb, FIND_BY_UNAME='text_message')

  widget_control, wText, SET_VALUE=str

  return, 1

end

;------------------------------------------------------------------------------

;+

; Class structure definition

;

; :Inherits:

;   IDLmiObserver

;  

; :Fields:

;   tlb: This widget ID of the dialog's top level base.

;-

pro roi_demo__define

  compile_opt idl2, logical_predicate

  void = {roi_demo           $

   

    , inherits IDLmiObserver $

    , tlb  : 0L              $

   

      }

end

;------------------------------------------------------------------------------

;+

;-

pro roi_demo

  compile_opt idl2, logical_predicate

  e = envi(/CURRENT)

  if ~isa(e, 'envi') then begin

    e = envi()

    eView = e->GetView()

    file = Filepath('qb_boulder_msi', ROOT_DIR=e.root_dir, SUBDIRECTORY=['data'])

    eRaster = e->OpenRaster(file)

    eLayer = eView->CreateLayer(eRaster)

    file = Filepath('qb_boulder_roi.xml', ROOT_DIR=e.root_dir, SUBDIRECTORY=['data'])

    eROI = e->OpenROI(file)

    nROI = n_elements(eROI)

    eLayerROI = objarr(nROI)

    for i = 0, nROI-1 do begin

      eLayerROI[i] = eLayer->AddROI(eROI[i])

    endfor

  endif

  oROIDemo = obj_new('roi_demo')

  oROIDemo->Dialog

end

1 comments on article "ENVI Extensions: Getting notifications from ENVI ROIs"

Avatar image

Mobit Solutions

I did not understand the program in the middle. I'll go through it again and I'll definitely try this in my seo company.

Please login or register to post comments.