How to identify objects in dynamic display


Summary It can be useful to display information from a selected set of objects while in dynamic display mode. This topic describes how to identify objects on the screen while in dynamic display mode.

Identifying objects in dynamic display

Identifying objects while in dynamic display mode is useful when gathering information about a particular item on the screen. Perform the following steps to use the Identify tool on your dynamic display objects:
  1. At draw time, add a watermark that will be used to identify the object. Use the OpenGL glLoadName() method. If you need additional unique identifiers, use it with glPushName()/glPopName(). If you need a single unique identifier, use IDynamicDisplay2.SelectionIdentifier. For example, if you're using it as part of an AfterDynamicDraw event implementation (and not as part of a layer implementation).

    The following code example shows how to add the object identifier (OID) as an OpenGL watermark to implement a hit test:
[C#]
uint ID = Convert.ToUInt32(r[0]);
OpenGL.GL.glLoadName(ID);
  1. Convert the identified point into window coordinates. Use the IDynamicDisplay2.Locate method to locate the available elements. To provide the best performance, if the elements are part of a given layer, use the layer's indication enum to instruct dynamic display to apply the selection query to the specified layer only. Calling the Locate method results in an array populated with the IDynamicHit array indicating the hit elements. Each dynamicHit will have unique IDs set by the call to glLoadName(). See the following code example:
[C#]
IEnvelope inEnv;
if (pGeom.GeometryType == esriGeometryType.esriGeometryEnvelope)
    inEnv = pGeom.Envelope;
else
    inEnv = pGeom as IEnvelope;
IArea area = inEnv as IArea;
if (area == null)
    return null;
int x, y;
m_displayTransformation.FromMapPoint(area.Centroid, out x, out y);
IArray dynamicHitArray = m_dynamicDisplay.Locate(x, y,
    esriDynamicSelectionMode.esriDSMLayers, this as IDynamicLayer);
if (dynamicHitArray == null)
    return null;
  1. Once the unique ID of the given hit object is obtained, use the relevant data from your layer data structure to create and populate the Identify object. The Identify object should be populated in an outgoing array that will be passed to the Identify dialog box. See the following code example:
[C#]
int count = dynamicHitArray.Count;
if (count == 0)
    return null;
IArray identifyObjArray = new ArrayClass();
IPropertySet propSet = null;
IIdentifyObj idObj = null;
IIdentifyObject idObject = null;
IDynamicHit dynamicHit = null;
for (int i = 0; i < count; ++i)
{
    dynamicHit = dynamicHitArray.get_Element(i)as IDynamicHit;
    if (dynamicHit == null)
        continue;
    // Get the record.
    DataRow r = m_table.Rows[dynamicHit.ObjectID];
    if (r == null)
        continue;
    // Instantiate a new Identify object.
    idObj = new MyDynamicLayerIdentifyObj();
    if (idObj.CanIdentify(this as ILayer))
    {
        // Populate a property set with the item's info.
        propSet = new PropertySetClass();
        propSet.SetProperty("OID", r[0]);
        propSet.SetProperty("X", r[1]);
        propSet.SetProperty("Y", r[2]);
        propSet.SetProperty("STEPX", r[3]);
        propSet.SetProperty("STEPY", r[4]);
        propSet.SetProperty("HEADING", r[5]);
        propSet.SetProperty("TYPE", r[6]);
        // Add the item to the outgoing array.
        idObject = idObj as IIdentifyObject;
        idObject.PropertySet = propSet;
        identifyObjArray.Add(idObj);
    }
  1. Populate the Identify dialog box with the information from the selected items in the array. See the following code example:
[C#]
string ESRI.ArcGIS.Carto.IIdentifyObj.Name
{
    get
    {
        string oid = String.Empty;
        if (m_propset != null)
        {
            oid = Convert.ToString(m_propset.GetProperty("OID"));
        }
        return "DynamidDataInfo_" + oid;
    }
}


See Also:

Dynamic display
How dynamic display works
Best practices for using dynamic display
Limitations for dynamic display
Dynamic display layer




Additional Requirements
  • This topic describes a method using third-party wrapper classes only available in C#; therefore, there is no VB .NET version available in the code sections.

Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView
ArcEditor
ArcInfo