Set Sketch Symbol on MapTool

2129
7
02-05-2021 09:37 AM
MatthewWinslett
New Contributor II

Hello,

I am using version 2.6 of the ArcGIS Pro SDK to develop a custom MapTool for a line feature, and I seem to be having trouble setting a symbol for the feedback.  Here is some relevant code:

In the constructor, I have these parameters set:

 

IsSketchTool = true;
SketchType = SketchGeometryType.Line;
SketchOutputMode = SketchOutputMode.Map;
UseSnapping = true;            
IsWYSIWYG = true;
SketchMode = SketchMode.Line;

 

 

In the OnToolActivateAsync method of my class I then set the symbol (after defining it) by calling:

 

SketchSymbol = _lineSymbolReference;

 

 

_lineSymbolReference is defined as:

 

CIMSymbolReference _lineSymbolReference = await QueuedTask.Run(() => { 
            CIMColor lineColor = CIMColor.CreateRGBColor(237, 28, 36);
            CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(lineColor, 1.5, SimpleLineStyle.Solid);
            return lineSymbol.MakeSymbolReference();
            });

 

 

When testing the tool in Pro, and drawing a sketch, the symbol always remains as the default symbol (the black dotted line, with the vertex symbols visible), though the symbol appears correctly after the sketch is finished.  Is there a way to have the symbol be used when drawing the sketch?

Thank you in advance for any help you might be able to provide!

7 Replies
NarelleChedzey
Esri Contributor

Matthew, 

 

I am not seeing any problems in 2.6 with the code you supplied.  This is what I have in my tool activation

CIMSymbolReference _lineSymbolReference = null;
protected override async Task OnToolActivateAsync(bool active)
{
  await base.OnToolActivateAsync(active);
  if (_lineSymbolReference == null)
  {
    _lineSymbolReference = await QueuedTask.Run(() => {
        CIMColor lineColor = CIMColor.CreateRGBColor(237, 28, 36);
        CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(lineColor, 1.5, SimpleLineStyle.Solid);
        return lineSymbol.MakeSymbolReference();
     });
  }

  SketchSymbol = _lineSymbolReference;
}

 

and this is what I see when I activate the tool and sketch for the first time.   

NarelleChedzey_0-1612559796350.png

 

Are you perhaps not wanting / expecting to see the green/red sketch vertices and the dotted sketch line that overlays your line?  

 

Thanks

Narelle

0 Kudos
MatthewWinslett
New Contributor II


Hi Narelle--


Are you perhaps not wanting / expecting to see the green/red sketch vertices and the dotted sketch line that overlays your line?  

That is indeed what I was trying to do, if it's possible?

Thank you,

Matt

0 Kudos
KirkKuykendall1
Occasional Contributor III

Well, I was going to suggest using ArcGIS.Desktop.Editing.SketchLineToolOverlayView, but it looks like Esri isn't allowing access ...

KirkKuykendall1_1-1612807863828.png

 

John_Jones
New Contributor III

Kirk, note that the type you are referencing `SketchLineToolOverlayView` isn't what you are looking for anyways it is the UserControl that we overlay on top of the MapView which contains the UI for the floating toolbar and onscreen constraints (if they are turned on).

As for customizing the sketch symbols, the Editing options on the backstage provides the user global access to configuring the symbology of the vertices of the sketch (red and green boxes by default) and some limited drawing options for the line (colors of the dashes and gaps and the symbol width). 

I think it reasonable to add properties to MapTool to optionally override these global settings so you can get your tool to look different than the default (used by internal tools and tools that don't choose to override these symbols).  Although there is merit to just letting the end user decide how they want the sketch symbology to be configured so they have the control to make it look visible on their map).  If you want to propose such an extension I suggest creating an 'Idea'.

Note also that the symbology options for the line of the sketch (dotted line by default) is limited because it doesn't support the full symbol model.  This is because the symbol is converted and rendered accelerated by the graphics hardware (where some line symbol properties in the usual symbol model would require drawing by software) so that it tracks the mouse as well as possible (note how it tracks much better than the `SketchSymbol` that Matthew is setting in the OP.

KirkKuykendall1
Occasional Contributor III

Hey John -

Thanks for the clarification.  I've submitted an idea here that mentions this.

0 Kudos
MatthewWinslett
New Contributor II

Hi Kirk and John--

Thanks for the replies.  I was afraid that it was something internal that hasn't been publicly exposed by Esri.  I'll work around it.  I'll also see about posting an idea, as John suggested.

-Matt

0 Kudos
Zoggo
by
New Contributor III

Is it necessary to call the base class? In the template code it looks always like this:

protected override async Task OnToolActivateAsync(bool active)
        {
            _EventToolAdd = (EventToolAdd)DockpaneViewModel.EventTool;
            _state = "von";
            CIMPointSymbol pointMouseMarker = await CreatePointMarkerAsync();
            _MousePositionOverlay = await AddOverlayAsync(geometry, pointMarker.MakeSymbolReference());
            if (!(DockpaneViewModel.EventTool is null))
            {
                (DockpaneViewModel.EventTool as EventToolAdd).Event.Reset();
            } 
            
             base.OnToolActivateAsync(active);
            return base.OnToolActivateAsync(active);
        }

But this it's not working unless I remove the return part. How can i do this proper?

0 Kudos