14 Replies Latest reply on Jun 27, 2013 4:45 AM by MBranscomb-esristaff

    LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay

    ahigh2
      Hello,

      I'm working through some performance issues with the accelerated display and have switched to working without it enabled. With the AcceleratedDisplay enabled, SimpleLineSymbols and LineSymbols both render correctly. If I turn it off, both fail to render completely. Nothing else has changed such as their geometries or symbologies. Is this a known issue and/or am I doing something wrong? Additionally, SimpleFillSymbols, PictureMarkerSymbols, and TextSymbols seem to work just fine regardless of AcceleratedDisplay settings.

      Thanks.

      EDIT: Code sample below

      private void MakeSimpleSymbol()
      {
                  //Create a simple line symbol
                  SimpleLineSymbol sls = new SimpleLineSymbol();
                  sls.Color = new SolidColorBrush(Colors.Blue);
                  sls.Style = SimpleLineSymbol.LineStyle.Solid;
                  sls.Width = 2;
      
                  //Create a polygon object
                  Polygon p = new Polygon();
                  p.SpatialReference = new SpatialReference(102100);
      
                  //Populate it with some points
                  ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection = new ESRI.ArcGIS.Client.Geometry.PointCollection();
                  ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection> rings = new ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection>();
                  MapPoint wgsPoint = new MapPoint(0,0);
                  MapPoint wgsPoint2 = new MapPoint(50,0);
                  MapPoint wgsPoint3 = new MapPoint(0,50);
                  pointCollection.Add(wgsPoint);
                  pointCollection.Add(wgsPoint2);
                  pointCollection.Add(wgsPoint3);
                  rings.Add(pointCollection);
                  p.Rings = rings;
      
                  //Create a graphic and set its properties
                  Graphic graphic = new Graphic();
                  graphic.Geometry = p;
                  graphic.Symbol = sls;
      
                  //Create a graphics layer and add the graphic to it
                  GraphicsLayer gLayer = new GraphicsLayer();
                  gLayer.Graphics.Add(graphic);
      
                  //Add the graphics layer to the map
                  _map.Layers.Add(gLayer);
      }


      And in the XAML:
      <Window x:Class="ESRIWPFTestApplication.MainWindow"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
              Title="MainWindow" Height="350" Width="525">
          <Grid>
              <!-- AcceleratedDisplay is OFF -->
              <esri:Map x:Name="_map" UseAcceleratedDisplay="False">
              </esri:Map>
          </Grid>
      </Window>
        • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
          ahigh2
          For what it's worth, an answer/workaround was posted to this question on Stack Exchange:

          http://gis.stackexchange.com/questions/58598/linesymbols-not-rendering-in-arcgis-runtime-for-wpf-sdk-10-1-1-without-accelerat

          Using ESRI.ArcGIS.Client.Geometry.Polyline objects instead of ESRI.ArcGIS.Client.Geometry.Polygon objects will allow the use of SimpleLineSymbols for representation in non-accelerated displays. It still seems a bit odd to me that I have to change a geometry object to continue to use a known symbology when I switch out of the Accelerated Display. Any additional input on this would be greatly appreciated.

          Thanks.
          • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
            helyxsisltd
            The Help on LineSymbol and SimpleLineSymbol say they are to draw Polyline objects. I'd therefore be tempted to shift to FillSymbol or SimpleFillSymbol, which are stated as being there to draw Polygon objects.

            SimpleFillSymbol has 2 properties that take a Brush. BorderBrush and Fill. If you don't want a fill, you could set the Brush.Opacity property on the Fill Brush to zero, to make it transparent.

            You're then left with all the flexibility of the Brush object to determine how your border looks.
            • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
              MBranscomb-esristaff
              Hi,

              It's a feature of the "accelerated" rendering engine at the core of the ArcGIS Runtime, that you can supply marker, line or fill symbols and they'll be applied to the appropriate sub geometry of your shape i.e. SimpleMarkerSymbols will be applied to the vertices of Polylines and Polygons and SimpleLineSymbols will be applied to the line segments of Polylines and Polygons. The original WPF based display does not follow the same pattern.

              Ideally, you should consider the "accelerated" display as the only display. However, currently there are some items which are not supported in the runtime core display, such as KML, clusterer renderers, temporal renderers.

              Cheers

              Mike
              • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                ankita_bhatia01
                Hi,
                I am using the Draw object and DrawMode.LineSegment to allow the enduser to draw a line between two points.

                The end points of the line are themselves graphic symbols. So actually the user would start drawing a LineSegment by clicking on one point graphic and will click on the next graphic to denote the end of draw.

                The problem I am facing is when I zoom in or Zoom out the End graphics move away from the end points of the line.
                As per my understanding both the Line Segment and the Graphics should move the same amount (and thus the endpoints will coincide with the graphics).

                Kindly help me resolve this issue.
                To mention: I am not using accelerated display coz I need to use clustering and customized Marker Symbols.
                • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                  MBranscomb-esristaff
                  Hi,

                  Are you able to post the code which demonstrates this?

                  Cheers

                  Mike
                  • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                    ankita_bhatia01
                    The code for drawing the Line in the DrawCompleted Event is
                      if (drawVertex1 && drawObject.DrawMode==DrawMode.LineSegment)
                                {
                                    GraphicsLayer gp = GetOrCreateGraphicsLayer("MyGraphicsLayer");
                                    if (this.selectedGraphic.Count == 1)
                                    {
                                        targetID = selectedGraphic.ElementAt(0).Attributes["NAME"].ToString();
                                    }

                                   var pipeSymbol =new SimpleLineSymbol() { Style = SimpleLineSymbol.LineStyle.Solid, Color = Brushes.Red, Width = 2 };
                                 
                                    viewMap.Cursor = Cursors.Arrow;
                                    Graphic g = new Graphic();
                                    g.Attributes["GraphicId"] = GraphicsCollection.Count;
                                    g.Attributes["SourceID"] = sourceID; //Start graphic
                                    g.Attributes["TargetID"] = targetID; //EndGraphic
                                    g.Attributes["TYPE"] = "XX";
                                    g.Geometry = e.Geometry;
                                    g.Symbol = pipeSymbol;
                                    g.Geometry.SpatialReference = new SpatialReference(102100);
                                    GraphicsCollection.Add(g);
                                    drawObject.IsEnabled = false;
                                    drawVertex1 = false;
                                    return;
                                }
                    The Graphics at the end points are Point graphics but have control templates defined as follows:
                      <esri:SimpleMarkerSymbol x:Key="StartSymbol">
                                <esri:SimpleMarkerSymbol.ControlTemplate>
                                    <ControlTemplate>
                                        <Grid>
                                            <!--  Marker  -->
                                            <StackPanel Orientation="Vertical">

                                                <Canvas>
                                                    <Ellipse Width="30" Height="15" />
                                                    <Path Width="30"
                                                          Height="15"
                                                          HorizontalAlignment="Left"
                                                          VerticalAlignment="Top"
                                                          Data="M 435.782,256.9C 410.699,256.9 390.365,244.15 390.365,228.421C 390.365,212.693 410.699,199.942 435.782,199.942M 585.239,199.942C 610.322,199.942 630.656,212.692 630.656,228.421C 630.656,244.149 610.322,256.9 585.239,256.9M 436.489,200.001L 585.822,200.001L 585.822,257.335L 436.489,257.335L 436.489,200.001 Z "
                                                          Fill="Azure"
                                                          Stretch="Fill"
                                                          Stroke="Black"
                                                          StrokeLineJoin="Round" />
                                                </Canvas>
                                                <TextBlock FontSize="12"
                                                           FontWeight="Bold"
                                                           Foreground="Black"
                                                           Text="{Binding Attributes[NAME]}" />
                                            </StackPanel>

                                        </Grid>
                                    </ControlTemplate>
                                </esri:SimpleMarkerSymbol.ControlTemplate>
                            </esri:SimpleMarkerSymbol>
                    • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                      MBranscomb-esristaff
                      Do you see the same behaviour with a regular SimpleMarkerSymbol?
                      • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                        ankita_bhatia01
                        Yes the same behavior happens even when I use a SimpleMarkerSymbol. (without any control template)
                        • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                          MBranscomb-esristaff
                          Hi,

                          I believe what you're seeing is just a product of the geometry of the start/end point of the line not being exactly the same as the points? i.e. - are you performing a hit test to determine which graphic the user has clicked/selected then using that as the start and end point?

                          To do this you could use the FindGraphicsInHostCoordinates method on the GraphicsLayer (http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.GraphicsLayer~FindGraphicsInHostCoordinates(Point,Int32).html).

                          ... Actually I see from your code the user should already have a graphic selected - therefore you could use the geometry of the point(s) the user has selected to create the line (to ensure the coordinates are coincident).

                          Regarding the cluster renderer - unfortunately that is not yet supported in the accelerated display mode. For custom symbols you could create them programmatically in code and use RenderTargetBitmap to render them as images then assign the image as a PictureMarkerSymbol.

                          Generally we also advise using a Renderer to apply symbols to all features in a layer rather than creating individual symbol instances per graphic.

                          Cheers

                          Mike
                          • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                            ankita_bhatia01
                            Hi Mike!
                            Strangely when I don't use the geometry returned by Draw object and create my own geometry,using the start and end point as the connected points, the line is not shown.

                            I drag my line from one symbol to another but the line does not appear.
                            • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                              ankita_bhatia01
                              Hi Mike!
                              I got this to work by explicitly calling the Complete Draw on MouseUp of the map and finding the Graphic on the clicked location.
                              Thanks for helping me out:)
                              • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                                MBranscomb-esristaff
                                That's great news, thanks for the update.

                                Cheers

                                Mike
                                • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                                  ankita_bhatia01
                                  Mike,
                                  I would like to understand why a geometry drawn with the Draw object behaved differently. According to me, it would have taken the location i was clicking on and on zoom both the graphic and the endpoint of the line would have moved equally.
                                  Thus giving me an appearance like I am getting now.

                                  Is there an explanation I am not able to figure out?
                                  • Re: LineSymbol and SimpleLineSymbol not rendering without AcceleratedDisplay
                                    MBranscomb-esristaff
                                    I'm not aware of anything in the API that would account for this (e.g. some form of scale-dependent precision) but my initial reaction is that perhaps it's something as simple as when digitizing you're at a sufficiently small scale to make the end of the line appear coincident with the point but in reality it's 100s/1000s metres away?

                                    Cheers