QT C++ code samples

More
21 Jul 2019 08:41 #140057 by Mike_Eitel
Replied by Mike_Eitel on topic QT C++ code samples
Hi Grotius
I'm no more in coding but remember strange results by "compiler optimization".
All sorts of.
M5C
Mike

Please Log in or Create an account to join the conversation.

More
22 Jul 2019 18:07 - 22 Jul 2019 19:37 #140209 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi Mike,

Thanks for your reply.

I'm no more in coding but remember strange results by "compiler optimization".

I solved it by making the formula outside of OpenGl. No complex issue. It can be a compiler problem. Short after my post
i got a QT update message. Maybe they spotted the same thing... If the problem still exist's it's not my problem anymore.
So i was a bit fast to publish this mathematical behavioure.

3d view (rotate) is implemented, was not hard, but i trapped myself... again .. Have to solve another thing.. I know what i did wrong...

My worst fault this week is to make visualisation's based on the sort array instead of the base array....
The base array has all the raw incoming data. This base array is the holy grail of the program. Without trusting the base array
the program is worth nothing...

So my vision is to alway's view first the raw dxf data (base array) to the user with OpenGL... This is very important.
In other word's... Show the base (auto)cad input to the user screen without any code manipulation.

Hmmm...

My stupid thing... Always the stupid tiny things...

I will change the code to fully 3d (it is already, but the array view has to change) and to base input code class again. ( tiny operation )

After that the classes (plasma or 3d milling) are free to use the code....

So you see Mike, every day we are learning about our code. You are a respected member over here !!
Last edit: 22 Jul 2019 19:37 by Grotius.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
25 Jul 2019 20:46 - 25 Jul 2019 22:04 #140565 by Grotius
Replied by Grotius on topic QT C++ code samples
Little project update :

Added 3d rotate zoom, now this works we can connect it to the right mouse button. Mouse rotate for x and z seem's good enough.


Added 3d path direction arrow's and start points.


Learned more about openGL this day. I started with line arrow's, but a cone looks nicer.
1. Draw a cone with the opengl triangle-strip
2. Move the cone to the position in the middle of the line
3. Rotate the cone within the direction of the line
4. Fabricate the next cone in the array for loop.

A raw code example for making a cone, it places the cone where you want, and it set's the cone direction :

Warning: Spoiler!


The axis gui :


I am thinking adapting cad function's into the cam program. To drawing lines, arc and circles. To make some fun with cad - cam !
And finally write a exiting file output for the users.
A clean dxf output combined with a ngc output. More languages and data pressed into one exiting file...
No one does this, because their program's are not written to read in multi levels. No one thought about it.
Attachments:
Last edit: 25 Jul 2019 22:04 by Grotius.
The following user(s) said Thank You: sivaraj, chimeno, tommylight

Please Log in or Create an account to join the conversation.

More
26 Jul 2019 07:48 #140631 by sivaraj
Replied by sivaraj on topic QT C++ code samples
Nice work.
Have you noticed with one tool path arrow direction are in both direction

Attachments:
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

More
26 Jul 2019 21:51 - 26 Jul 2019 23:23 #140692 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi Sivaraj,

I did not see that. But i know where to find this problem. It's in the contour recognize class.
The problem has to do with swapping the direction of the little arc at your red arrow line.
Later on i will improve this class.

The blue direction lines are telling the truth. :lol: Thanks for your spot !

Today i added :
- dimensions, see left corner at bottom. It's called the statusbar. This statusbar is useless at this moment.
This statusbar must be hacked up into several useful pieces.
It works with zoom, movement's etc. This was a hard piece to understand.
If you click on the screen, it will give you the actual cad coordinates. And later on it will give you actual line lenght.
Something that draftsight is not doing... When you draw a line in drafsight, you don't see the lenght at your mouse point...

- click the line near the start point (can be expanded to more item's like endpoint or window select) and the line is selected,
see the color change to orange. ( now we have the basics of a interactive opengl screen )

- changed line thickness in opengl, this was easy.

- added the 3d rotate to the right mouse button, this was more difficult, but works very nice.

DxfDecoder gui :


For the rest i spotted a G41.1 / G42.1 issue. At least, that is a issue for me for this moment.
Later on i will post more about this.

The inner circle is with G41.1 D0, tool diameter 0 no offset. This goes perfect !!
The outher circle is with G41.1 D1, tool diameter 1 offset left of path.



The problem is with the outher circle. At lead in and lead out, the product is not finisched. Is there a overcut G code command?

At the fire spot.. This material will stay on the cutted product (circle). That is a problem. This non cutted material is between the start radius lead in and the end radius lead out, wich is in this case 0.
Attachments:
Last edit: 26 Jul 2019 23:23 by Grotius.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
27 Jul 2019 20:06 - 27 Jul 2019 20:08 #140764 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi dear liinuxcnc users..

We have a little project update today.

Added button's to the toolbar. It are dockable toolbars, splitted up into more little movable toolbar's just like in cad.
Added the axis origin arrow's for xyz. You can disable them with a toolbar select button.



To test this release :
we.tl/t-Km5u0JAgJE

To start, unzip and type in terminal : ./DxfDecoder

I think this release will work now on a standard debian installation. It's no longer depending of QT open libraries.
Not tested this on standard debian, ubuntu or wathever, but i expect this release is going to work for linux.

No longer needed dependencies :
<QOpenGLWidget>
<QtOpenGL>
Attachments:
Last edit: 27 Jul 2019 20:08 by Grotius.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
30 Jul 2019 13:39 #140950 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,

Today i started with calculating the outside contour offset of a product. To compensate kerf width for plasma
and milling. Calculating the inside offset has the same principle. This example is for lines at this moment.
Finding circle and arc intersection's is the next level to do.

Attached i a picture of a product 100x100mm that have 2 lines that are offset 5mm from the product.
To find the new closed contour point, see the yellow circle, we have to do a calculation for finding this point. It's called intersection point.



The C++ code sample :
Warning: Spoiler!


The tested console output :

determinant is : -2495
intersection point is x : 52.097 y : 105


So nice that this works !!

Attached the QT intersection project in zip format.
Attachments:
The following user(s) said Thank You: chimeno, tommylight

Please Log in or Create an account to join the conversation.

More
30 Jul 2019 19:14 - 30 Jul 2019 19:48 #140971 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,

Thanks to chimeno & tommylight !

Me was lucky today... Made the circle and line intersection code ready quite quickly...

Attached a QT project for searching the intersecting point of a line and a circle.
This basic code can be a template for intersecting lines with arc's too.

The cad drawing with a line and a circle. The red dimension lines are calculated by the C++ code.


The C++ code :
Warning: Spoiler!


The console output of this example :

Two solutions x1 : 9.55418 y1 : 5.75232
Two solutions x2 : 3.14394 y2 : 2.19108


This Circle and line intersecting QT C++ project is attached for downloading.

Another offset example :

In this example we got a 5mm outside offset for the product.
The green lines are done by the line-line intersection methode in my previous post today.
If we see a line followed by an arc in the memory array, we do a line-circle intersection like below.
Offset of the arc is 5mm.



Code :
Warning: Spoiler!


Console output :
Two solutions x1 : 90.4489 y1 : 66.7792
Two solutions x2 : 66.6837 y2 : 90.3977


We need the closest solution. The closest founded intersection point related to the line. We can make a little formula for that with if, else.

The yellow circle is the calculated intersection point of a line collision with an arc. :woohoo:
Attachments:
Last edit: 30 Jul 2019 19:48 by Grotius.

Please Log in or Create an account to join the conversation.

More
30 Jul 2019 20:48 - 30 Jul 2019 21:32 #140976 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,

The last item to investegate was find the intersecting point of a circle with a circle.

Cad drawing of product with a contour offset 5mm. Find where the 2 circle's collide..


Attached QT C++ project find intersection circle to circle.

File Attachment:

File Name: QT_circle_...tion.zip
File Size:49 KB


console output :
intersection x1 : 74.0697 y1 : 57.5247
intersection x2 : 92.4753 y2 : 75.9303


We have 2 solution's. We calculate wich one we need with a if else statement.

What do we do with the tiny line in within the red circle? Delete it automaticly?

The QT C++ code for intersecting circle to circle :
Warning: Spoiler!


Okey we have to go on with the next level.
Add contour offset's to the product.....

The swap class needs some improvement's, but i will try add some contour offsets first.
We have classes for line-line, line-circle and arc-arc interceptions. Without that we where lost.
But now we have more power to make offsets. B)



Glad to be back to the relaxed DxfDecoder screen.
Attachments:
Last edit: 30 Jul 2019 21:32 by Grotius.
The following user(s) said Thank You: tommylight, emilvv

Please Log in or Create an account to join the conversation.

More
01 Aug 2019 14:14 - 01 Aug 2019 18:03 #141110 by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,

Today i have a C++ example for finding a new xy offset point of a certain line. In this example the offset is 10mm.

We have the x0,y0 (0,0) and x1,y1 (200,100) points. This are the points that form the blue product line C.
We have to calculate the offset point of the blue line, see yellow circle.

Visualisation of the calculation..


Attached the QT project for this example, the zip includes the cad drawing.
The C++ code spoiler down here has some updated code... Don't forget this...

File Attachment:

File Name: QT_offset_...oint.zip
File Size:45 KB


Console output :
this calculation is between 0 and 180 degrees, the new x is : 204.472 new y is : 91.0557 (alpha 3)

The output in DxfDecoder. Tested in all quadrants. The calculated point is the endpoint of the short blue line wich has
the offset lenght of 10mm in this case. The blue line is perpendicular to the base line. The yellow lines are opposites of the blue line.
The yellow line was founded by only a + and - calculation related to the blue line.


This is nice !!

We can now draw a offset line with opengl.
After that, we can do the intersection calculation for line-line to close the contour... Yes yes..

These separate software step's (tutorials) combined (in total) will result in the base code for a complex contour offset algoritme.
Don't forget the power of Linux !! B) It's all in the game...

C++ code: (angle1 = alpha1 and so on)
Warning: Spoiler!



For a quick test we add the offset lines to the opengl class :

Later on we will copy this test to a new class and keep the opengl as clean as possible.

Next item is to execute the intersection line-line class forum.linuxcnc.org/41-guis/36768-qt-c-co...ples?start=60#140950 to find all the intersection point's... This we will do tomorrow !

If i look at the current output, we can use this for generating press brake products..
Attachments:
Last edit: 01 Aug 2019 18:03 by Grotius.
The following user(s) said Thank You: phillc54, tommylight

Please Log in or Create an account to join the conversation.

Time to create page: 0.384 seconds
Powered by Kunena Forum