Select to view content in your preferred language

Feature Selection is Invisible

703
9
03-20-2012 03:12 PM
GeorgeFaraj
Frequent Contributor
I have a program in ArcEngine that displays a map. When I use a tool to select from the single feature layer that is Selectable the selection is drawn on the map using the symbol I have specified for the FeatureSelection.SelectionSymbol. This all works fine all day long. I then define a unique values renderer for that feature layer and activate it. Now when I select features in that layer they are invisible (they are there, I just can't see them - the symbol does not get drawn on top of the renderer symbol.) This is NOT a refresh issue!  I have refreshed the GeoSelection (and everything else) a 1000 different ways and as long as a renderer is active I cannot see the feature selection.  How do I get a feature selection to draw on top of everything???
0 Kudos
9 Replies
GeorgeFaraj
Frequent Contributor
I can see (by capturing the AfterDraw) that the view is redrawing in the specified order:

    esriViewBackground
    esriViewGeography
    esriViewGraphics
    esriViewGeoSelection
    esriViewForeground

but still I don't see the selection when a renderer is active - does it work this way in ArcMap?
0 Kudos
AlexanderGray
Honored Contributor
Have you raised the selection changed event?  If the selection is done on the featurelayer it is the IFeatureSelection.SelectionChanged method.
0 Kudos
GeorgeFaraj
Frequent Contributor
Have you raised the selection changed event?  If the selection is done on the featurelayer it is the IFeatureSelection.SelectionChanged method.


Are you saying that I should have this code:

                
IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
featureSelection.SelectionChanged();


after the actual selection so that the map control knows that the feature selection has changed and must be redrawn? Didn't change anything. (I know the selection is actually taking place because I read the SelectionCount and update my status bar with that value.) The symbol (a hollow fill with bright colored lines) does not get drawn over the renderer fills but draws fine when no classification renderer is active.

If this is just supposed to magically 'work correctly' then what could I be doing to cause it to fail? There's nothing special about my map. No extensions, caches, dynamic displays or anything like that is active. The afterDraw shows (in order):

drawn: initialize view
drawn: background
drawn: geography
drawn: graphics
drawn: selection
drawn: foreground

I would tear my hair out but that doesn't make any more sense than what the program is doing.
0 Kudos
AlexanderGray
Honored Contributor
Strange.  Are you defining the unique value renderer and the custom selection symbol in your code?  If you back up and set the layer's symbology and selection symbol in ArcMap (if available) for example and load the lyr or mxd in your engine application, do you get the same problem?  Do you get the problem with the selection not drawing in ArcMap too.  What if you use a simple symbol for the selection, do you get the same problem?
0 Kudos
GeorgeFaraj
Frequent Contributor
Strange.  Are you defining the unique value renderer and the custom selection symbol in your code?  If you back up and set the layer's symbology and selection symbol in ArcMap (if available) for example and load the lyr or mxd in your engine application, do you get the same problem?  Do you get the problem with the selection not drawing in ArcMap too.  What if you use a simple symbol for the selection, do you get the same problem?


Have to do some hoop jumping to get ArcMap running again (license ran out) but yes I am defining selection symbol and unique (and numeric) renderer in code.  Turned off selection symbol and got the Cyan lines which exhibited the same behavior. It just appears that when a renderer is active "geoFeatureLayer.Renderer = featureRenderer;" then the selection will not overwrite the rendered polygons.

This is how I get my symbol for the renderer (when esriGeometryType.esriGeometryPolygon):

// symbol is current symbol, 
// enumColor is just a predefined style gallery color ramp
symbol = GetFillSymbol( symbol as ISimpleFillSymbol, enumColors.Next(), 1 );

private ISymbol GetFillSymbol( ISimpleFillSymbol simpleFill, IColor nextColor, double size ) {

    if ( simpleFill == null )
        simpleFill = new SimpleFillSymbolClass();
    ILineSymbol lineSymbol = new SimpleLineSymbolClass();
    lineSymbol.Width = size;
    simpleFill.Color = nextColor;
    simpleFill.Outline = lineSymbol;

    return simpleFill as ISymbol;
}

//And I add it to the renderer with:
uniqueValueRenderer.AddValue( currentBreak, ClassifyFieldName, symbol );


Can you actually create a renderer and select over it in ArcMap?
0 Kudos
GeorgeFaraj
Frequent Contributor
I narrowed my problem down.

If I apply a unique classification to a feature layer only then my selection code draws the selection on the map just as it should.
If I apply a unique classification to a feature layer joined to an underlying SQL table using a memory relationship then the selection will not draw on the map!

Help! Can anyone see why this might be?
0 Kudos
AlexanderGray
Honored Contributor
Are you apply the query filter, do you define the where clause with the table names qualified for the fields?  If you look at the displayselectionset from the IDisplayTable, are there any rows selected?
0 Kudos
GeorgeFaraj
Frequent Contributor
Are you apply the query filter, do you define the where clause with the table names qualified for the fields?  If you look at the displayselectionset from the IDisplayTable, are there any rows selected?


I use a selection routine that selects by shape (ActiveView.FocusMap.SelectByShape() based on the geometry selected by the tool.) If I cast and examine the layer after the selection then yes, the DisplaySelectionSet shows the correct count whether the selection is visible (no join) or not visible (feature layer is joined to SQL table.) I am correctly qualifying the join based on the uniquely generated dataset name and the classify is actually working because the proper colors are displayed for each unique value.

Is there something about a join that should cause the graphics to redraw in different order than is specified by the documentation? What is drawn by esriViewForeground? (That is the only thing that the "after draw handler" shows after esriViewGeoSelection.)
0 Kudos
AlexanderGray
Honored Contributor
Foreground is used to draw directly to the display with the IDisplay.  You can do some neat things with it but the elements are gone on the next refresh (unless you draw in the after refresh event.)  I used it with engine to make a custom edit tool at 9.3.  I doubt it has any thing to do with this problem.
0 Kudos