Object Selection

With object graphics, the process of selection is very similar to drawing, except that nothing is displayed on the screen, and information about which objects were selected is returned to the user. Selection is performed via the Select method of an IDLgrWindow object.

Three types of objects may be selected: view objects, model objects, and visualization objects. For a given scene that contains more than one view, you can use the Select method to determine which view is selected at a given location. Likewise, for a given view, you can use the Select method to determine which models and/or visualization objects within that view are selected.

An object is considered to be selected if its graphical rendering falls within a box centered on a given location. The dimensions of the box are set via the DIMENSIONS keyword to the Select method. Both the location argument and dimensions keyword values are measured in units specified via the UNITS keyword.

The Select method returns a vector of objects, sorted in depth order (nearest to the eye is first), that meet the criteria of having been selected at the given location. If no objects are selected at the given location, the Select method returns –1.

See "IDLgrWindow::Select" (IDL Reference Guide) for a detailed description of the Select method.

Selecting Views

To determine which of a set of views within a given scene are selected at a given location, call the Select method on an IDLgrWindow object with an instance of an IDLgrScene object as its first argument, and the location at which the selection is to occur as its second argument:

myLoc = [myMouseEvent.x, myMouseEvent.y]  
mySelectedViews = myWindow->Select(myScene, myLoc) 

Selecting Visualization Objects

To determine which visualization objects within a given view are selected at a given location, call the Select method on an IDLgrWindow object with an instance of an IDLgrView object as its first argument, and the location at which the selection is to occur as the second argument:

myLoc = [myMouseEvent.x, myMouseEvent.y]    
mySelectedGraphics = myWindow->Select(myView, myLoc) 

Note
If a model within the view is set as a selection target, the model object, rather than its contained visualization objects, is returned in the vector of selected objects.

Selecting Models

In some cases, a group of visualization objects may be considered subcomponents of the model in which they are contained. As a result, you may want to know when a model object (rather than one or more of its contained visualization objects) has been selected. To enable selection of a model (rather than its visualization objects), the model object must be marked as a selection target.

To mark a model as being a selection target, set the SELECT_TARGET property of the model object to a nonzero value.

myWindow = OBJ_NEW('IDLgrWindow') 
myView = OBJ_NEW('IDLgrView') 
myModel = OBJ_NEW('IDLgrModel')    
myView->Add, myModel 
myModel->SetProperty, /SELECT_TARGET 
myAxis = OBJ_NEW('IDLgrAxis', 0) 
myModel->Add, myAxis 
myWindow->Draw, myView 

In the above example, if a selection at location [myX, myY] would normally select the axis object, the returned value of the Select method will be the object reference to myModel rather than the object reference to myAxis.