Add SymbolStyle as Symbol to Graphic object.

203
5
11-10-2017 01:33 AM
GeorgeArnaut
New Contributor II

Thanks for answering my question Lucas, you also added this great example how to use an arrow! Thank you!

This lines realize connection between SymbolStyle and Point!   


// connect  symbolstyle signal
  connect(m_symbolStyle, &SymbolStyle::fetchSymbolCompleted, this, [this](QUuid, Symbol* symbol)
  {
    m_simpleRenderer->setSymbol(symbol);
  });


But I want to put SymbolStyle  object in Graphic object like this:

lineGraphic = new Graphic(polylineBuilder.toGeometry(),sls,this);


where sls is pointer to SymbolStyle object. Is It possible. I didn't found methods in this class, only signal (this technic also was used in the sample.)

0 Kudos
5 Replies
LucasDanzinger
Esri Frequent Contributor

With graphics, you can either symbolize by explicitly giving the Graphic a Symbol, or you can set a Renderer on the GraphicsOverlay, and all Graphics inside of that overlay will display with the Symbol defined in the Renderer. I chose the renderer method for this example. You could store the symbol as a member variable, and then create a Graphic with that Symbol if you like:

 connect(m_symbolStyle, &SymbolStyle::fetchSymbolCompleted, this, [this](QUuid, Symbol* symbol)
{
  m_arrowSymbol = symbol;
});

...

Graphic* graphic = new Graphic(polylineBuilder.toGeometry(), m_arrowSymbol, this);
0 Kudos
GeorgeArnaut
New Contributor II

Thank You Lucas! I tried this example, I expected to print an arrow, that would replace 2 points created by PolylineBuilder, but it didn't happen.  It works only if I'm add this symbol to renderer and no other methods gives me the same result. What can be wrong?

Code here:

m_arrowSymbol - pointer to Symbol, exist as private field of the class.

after, all as in your example:

connect(m_symbolStyle, &SymbolStyle::fetchSymbolCompleted, this, [this](QUuid, Symbol* symbol)
  {
    m_arrowSymbol = symbol;
  });

m_polylineBuilder->addPoint(-10e5, 40e5);
m_polylineBuilder->addPoint(20e5, 50e5);
m_graphic = new Graphic(m_polylineBuilder->toGeometry(),m_arrowSymbol,this);
m_graphicsOverlay->graphics()->append(m_graphic);

But it show only 2 big red points. I want to create an arrow, without adding arrow symbol to all objects.

Please look at this, I don't know why it doesn't work.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

It should work whether you set it on the renderer or on an individual graphic. In your code, have you made sure it isn't some timing issue? Perhaps the graphic is getting created before the symbol is fetched from the SymbolStyle? Also, have you verified that the fetchSymbolCompleted signal is firing?

0 Kudos
LucasDanzinger
Esri Frequent Contributor

I also want to add that with our next release (due out at the end of the year), we will have a way to create a line symbol with an arrow, without having to do the entire Pro SymbolStyle workflow.

0 Kudos
GeorgeArnaut
New Contributor II

Thank you Lucas! The main problem was in a signal. I fix it.

0 Kudos