(ARCGIS SDK for Qt C++ version 100.5 ) Point Symbols/Graphics not always displaying

438
2
11-03-2020 01:43 PM
RobLefebvre
New Contributor II

I am creating polygons on my map, with SimpleMarkerSymbol point symbols at each vertex.  When I create them from code (no interactive clicking, etc.), The point symbols sometimes don't display.  If I subsequently move the vertex interactively, the symbol shows up.  I am doing a repaint of the view after creation.  I have tried moving the point, but it doesn't help, dynamically (in code).  It is as if it needs to come from a view event (mouse click, etc.) before they will show.  However, in one case, when I create them, they work every time. (I have two different paths, one that reads an init file to create saved polygons - that works, and one where I query a database for lines, create a polygon around the line - that doesn't work)  Any ideas? 

I am creating a PolylineBuilder to collect the points, then creating a PolygonBuilder from its geometry once the user is done.  I then create a Graphic with the PolygonBuilder geometry, check its validity, then create a graphic and add it to the Graphics Overlay that is displaying them.  I have tried setting the ZIndex, thinking that maybe they were there, but under something, but no success there either.

Rob

0 Kudos
2 Replies
RobLefebvre
New Contributor II

In trying to determine what was actually going on here, it appears that the issue was that the point graphic(s) were getting in a "strange" state.  On creating the polygon, I use a PolylineBuilder to collect points from the user (or, in this case, code), then, when the point collection is done, convert the lineBuilder to a polygon and create a graphic to display it.  In the creation of the polyline, to define the polygon, I place a Point graphic (SimpleMarkerSymbol for display), at each vertex of the line/polygon.  These point graphics are added to a member variable QList, so that we can track them.  When the collection is complete, a polygon is created from the Polyline points, then the graphics for the temporary polyline (and point graphics at vertices) are removed from the GraphicsOverlay.  Then a Polygon Graphic is created and added to the Overlay,  At this point, the QList of vertex graphics was iterated over, and added back to the overlay.  This is where the problem cropped up - apparently, when they were removed from the overlay, in cleaning up the line graphic, they were not deleted, but got in a state where they would not display properly (or at all).  By re-creating a new graphic for each vertex, they now show up.  Odd that the documentation  doesn't have any discussion (that I could find), that tells what happens to Graphics when added and/or removed from a GraphicsOverlay.  If a graphic is no longer able to be displayed, it would be good to know this...

0 Kudos
LucasDanzinger
Esri Frequent Contributor

When you remove the graphic from the overlay, what exactly are you doing? Calling removeOne and then explicitly deleting the graphic object? Or perhaps you are using smart pointers or setting a parent on the graphics and symbols, then deleting the parent object? I agree, it sounds like things are getting into a weird state somehow. Are you able to share any code? 

0 Kudos