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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

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

mad-hatter
Hello,

I wonder if somebody could help?
I'm writng an add on (C++) for LibreCad that will allow one to divide an entity
in to multiple even segments, so far I've managed to select a line, drawn at any
position and angle , divide it and get a list of x-y pairs. I can't work out which
of the existing functions to use to draw my dividing lines. I'll think about dividing
the line later, for now I just want be able to draw lines.
Suggestions please.

Redards

When finished I'll make it available to LibreCad users.

//Data I have:-
line x1-y1, x2-y2   -11.6315 -12.8005  -   -10.2243 -14.8783   on layer 2
line x1-y1, x2-y2   -4.70536 -8.10979  -   -3.29815 -10.1876   on layer 2
line x1-y1, x2-y2   2.22076 -3.41909   -   3.62797 -5.49692    on layer 2
line x1-y1, x2-y2   9.14688 1.27162    -   10.5541 -0.806215   on layer 2
line x1-y1, x2-y2   16.073 5.96233     -   17.4802 3.88449     on layer 2


Reply | Threaded
Open this post in threaded view
|

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

LordOfBikes
Administrator
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
Reply | Threaded
Open this post in threaded view
|

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

mad-hatter
In reply to this post by mad-hatter
Hello,

Librecad menu about:-
Qt Creator 4.6.0
Based on Qt 5.10.1 (MSVC 2015, 32 bit)

I'm using source:- LibreCAD-2.2.0-rc1.zip to finish my plugin,
and getting the following errors with includes.
These files do exist.

These files not found:-
//#include "qg_layerwidget.h"
//#include "rs_graphic.h"
//#include "rs_layer.h"
//#include "rs_entitycontainer.h"
//#include "rs_graphicview.h"

These files found:-
//#include "H:\Qt\librecad-master-21\librecad\src\ui\qg_layerwidget.h"
//#include "H:\Qt/librecad-master-21\librecad\src\lib\engine\rs_graphic.h"
//#include "H:\Qt\librecad-master-21\librecad\src\lib\engine\rs_layer.h"
//#include "H:\Qt\librecad-master-21\librecad\src\lib\engine\rs_entitycontainer.h"
//#include "H:\Qt\librecad-master-21\librecad\src\lib\gui\rs_graphicview.h"

This is on a new system, my old computer was destroyed.
Is there something to set up in the paths or something missing in "LibreCAD-2.2.0-rc1".

The plugin works up to a point, I just need to finish the interface.

Regards

Reply | Threaded
Open this post in threaded view
|

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

LordOfBikes
Administrator
You should post the whole output of make, so we can see what is going on. Or do you have a github repo where we can see your modifications?

Does this happen when LibreCAD is build or when it comes to your plugin?

Armin
investing less than half an hour into Search function can save hours or days of waiting for a solution
Reply | Threaded
Open this post in threaded view
|

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

mad-hatter
This post was updated on .
Hello,

I've posted the my plugin surce on DropBox.
Files on DropBox.

I can compile and run LibreCad when I add in my plugin, it works, I want to improve it.

Its just when I try and include the files shown in my previous post, I get file not found.
The filles are there, thats why I mentioned mayby a path issue with Qt Creator or LibreCad.

Regards
Reply | Threaded
Open this post in threaded view
|

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

LordOfBikes
Administrator
So you want to include header files from librecad sub project into your plugin sub project.
Then you have to append the paths to the INCLUDEPATH variable in the plugin project file.
This is not related with Qt Creator, only a project property setting issue.

But I assume, that this is not a good idea and will bring more trouble. The plugin interface class should be the only common used source between the main application and the plugin.

Armin
investing less than half an hour into Search function can save hours or days of waiting for a solution
Reply | Threaded
Open this post in threaded view
|

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

mad-hatter
Hello,
LordOfBikes wrote
But I assume, that this is not a good idea and will bring more trouble. The plugin interface class should be the only common used source between the main application and the plugin.
OK, I've changed the souce to reflect your comments.

DropBox has been updated.

For the moment only ticks on lines and circles are working.

Regards


Reply | Threaded
Open this post in threaded view
|

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

mad-hatter
Hello,

I can now draw ticks on lines, circles and arcs.

I would like to break(divide) the entity at the intersection of the ticks on the lines, circles and arcs.

I've looked at 'rs_actionmodifycut' but this requires user interaction.

What should I look at to enable me to divide an entity from my program?

Regards