I've made a custom tool for digitizing polygons in qgis, similar to build in Add Feature tool but with some modifications. I need to integrate tracing into that tool also, but I haven't figured out how.

I know that in the API, there are QgsMapCanvasTracer class and QgsTracer class, but I don't know how to use them in my custom tool.

It would be create, if someone can give me some hints or examples regarding this topic? Google can't find anything regarding this.


I would refer the documentation and code provided QgsMapCanvas Class Reference, [qgsmapcanvastracer.cpp](https://qgis.org/api/qgsmapcanvastracer_8cpp_source.html respectively

  : mCanvas( canvas )   
  35   , mMessageBar( messageBar )   
  37 {   
  38   sTracers.insert( canvas, this );   
  40   // when things change we just invalidate the graph - and set up new  
  parameters again only when necessary   
  41   connect( canvas, &QgsMapCanvas::destinationCrsChanged, this,  
 &QgsMapCanvasTracer::invalidateGraph );   
  42   connect( canvas, &QgsMapCanvas::layersChanged, this,  
 &QgsMapCanvasTracer::invalidateGraph );    
  43   connect( canvas, &QgsMapCanvas::extentsChanged, this,  
 &QgsMapCanvasTracer::invalidateGraph );   
  44   connect( canvas, &QgsMapCanvas::currentLayerChanged, this,  
 &QgsMapCanvasTracer::onCurrentLayerChanged );   
  45   connect( canvas->snappingUtils(), &QgsSnappingUtils::configChanged,  
 this, &QgsMapCanvasTracer::invalidateGraph );    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.