Re: LibreCad-2.2.0.alpha - Need help with drawing a line in C++

Posted by LordOfBikes on
URL: https://forum.librecad.org/LibreCad-2-2-0-alpha-Need-help-with-drawing-a-line-in-C-tp5715519p5715520.html

You may have a look at the sample plugin source \plugins\sample\sample.cpp
or one of the other plugins how to create entities.

The sample plugin asks for two points and create a line between them.
The method where the line is added is:
lc_Sampledlg::processAction(Document_Interface *doc)

And the magic is done here:
    doc->addLine(&start, &end);

Read the Document_Interface class to learn its possibilities.
The Document_Interface class grant you access to the current RS_Document, which contains the current drawing.
This is how it works, you don't have to draw anything yourself, that is done by the application. In the plugin, you modify the document by removing and adding entities.

Look at the existing plugins to see how to iterate over all or only selected entities.

You can delete the original line with Document_Interface::removeEntity() or keep it and add the split lines on a different layer.
For the split lines you may use Document_Interface::addLines() or  Document_Interface::addPolyline().

Good luck!
investing less than half an hour into Search function can save hours or days of waiting for a solution