QT C++ code samples
13 Aug 2019 15:34 - 13 Aug 2019 16:07 #142034
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,
Thanks Tommy and OPW !!
We have good news today.
Did some extra work on the main window. Will update the icon's soon to new grotius made icon's
Updated the code yesterday for a ellipse. The ellipse is half drawed for now. The half ellipse is build up from multiple arc's what
is nice for a cam output !! This was a very long C++ code to write so far. It has ortho on and off included so far. Later on i will finish
the ellipse draw function and will look for the new ellipse chamfer function.
The opengl screen is now auto resize with the main window and has the screen ratio included.
The opengl timer is updated, i had a problem that the timer was somehow delaying the program after a few minutes. Like a overflow.
The widget margin's are up to date now. Margins are hard to find in QT. But now i know how to set them correctly.
We can draw at this moment :
-line (ortho on or off)
-line strip (ortho on or off)
-2 point circle
-3 point circle
-arc (very good arc function, above expections !)
-rectangular
-polygon with user defined segment's. A 3 side polygon is a triangle, a 4 side polygon is a nice square rectangle, with ortho on and off.
-half ellipse (builded up from multipe arc's, can be expanded to unique ellipse chamfer function)
Thanks Tommy and OPW !!
We have good news today.
Did some extra work on the main window. Will update the icon's soon to new grotius made icon's
Updated the code yesterday for a ellipse. The ellipse is half drawed for now. The half ellipse is build up from multiple arc's what
is nice for a cam output !! This was a very long C++ code to write so far. It has ortho on and off included so far. Later on i will finish
the ellipse draw function and will look for the new ellipse chamfer function.
The opengl screen is now auto resize with the main window and has the screen ratio included.
The opengl timer is updated, i had a problem that the timer was somehow delaying the program after a few minutes. Like a overflow.
The widget margin's are up to date now. Margins are hard to find in QT. But now i know how to set them correctly.
We can draw at this moment :
-line (ortho on or off)
-line strip (ortho on or off)
-2 point circle
-3 point circle
-arc (very good arc function, above expections !)
-rectangular
-polygon with user defined segment's. A 3 side polygon is a triangle, a 4 side polygon is a nice square rectangle, with ortho on and off.
-half ellipse (builded up from multipe arc's, can be expanded to unique ellipse chamfer function)
Attachments:
Last edit: 13 Aug 2019 16:07 by Grotius.
The following user(s) said Thank You: phillc54, tommylight
Please Log in or Create an account to join the conversation.
- tommylight
-
- Away
- Moderator
-
Less
More
- Posts: 18563
- Thank you received: 6218
13 Aug 2019 16:06 #142040
by tommylight
Replied by tommylight on topic QT C++ code samples
Hmmmm......your screen resolution keeps getting bigger and bigger ! ![:) :)](/media/kunena/emoticons/smile.png)
Thank you for all the effort you are putting in it, and some other things, too.
![:) :)](/media/kunena/emoticons/smile.png)
Thank you for all the effort you are putting in it, and some other things, too.
The following user(s) said Thank You: Grotius
Please Log in or Create an account to join the conversation.
14 Aug 2019 00:31 - 14 Aug 2019 01:49 #142098
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi Tommy,
Thanks...
Resolution is a gamer screen 1ms. Very big indeed. But 45 watts. My old screen was consuming a lot of power....
This new screen, it uses the displayport. I had a problem. The screen did not show up.... Hahahaha.
www.lg.com/nl/monitoren/lg-32GK650F
I updated the debian kernel for this. Resolution more then 2500x1400.
On this forum i posted a how to link at a kernel testers topic for debian 9.
Related to the DxfDecoder, the name can be changed in something else. It's not a decoder anymore. This was the first step, at that time a nice name.
One of the next things to write in C++ is a object move and rotate function. The rotate function is quite easy. The move function is quite easy too. The object move and rotation function is in fact a preprocess step of the auto nesting algoritme. A good practice for a lazy sunday. I don't think we can write the nesting algoritme in one lazy sunday... Haha..![:woohoo: :woohoo:](/media/kunena/emoticons/w00t.png)
The rotate function is already used for drawing a polygone. The spline function we will not adapt coming time, i think this will take to much time to investegate. And a spline can be funest for Cam. Controlling a cad formed arc-strip can be a better option.
First finish the cad section, then update the cam section. Then provide a free cad/cam version. Must make a auto installer in the mean time too... Hmmm.. nice... I am no autodesk company... But almost looking at autodesk, one of the most richest company's ww. We have soon more exotic features then draftsight ( a autodesk product), i promise the linux users. Hhahahahaha. Just liking the way linux is going to defeat window's and autodesk in a few years from now.
For the cad section i will make also the following function's the coming time :
- snap to endpoint, midpoint, perpendicular intersection etc.
- trim and extend. ( extend a line without selecting a target is possible, this is also a new cad function )
- scale
- stretch
- fillet with radius
- fillet with ellipse (new, material reduction, perfect line's)
- chamfer corners
So a lot to do. But we have time. And it's not very difficult to code anymore. We know what we are doing bro...
Tonight I made some icon's with inkscape.. Inkscape is a nice free program !!!
Thanks...
Resolution is a gamer screen 1ms. Very big indeed. But 45 watts. My old screen was consuming a lot of power....
This new screen, it uses the displayport. I had a problem. The screen did not show up.... Hahahaha.
www.lg.com/nl/monitoren/lg-32GK650F
I updated the debian kernel for this. Resolution more then 2500x1400.
On this forum i posted a how to link at a kernel testers topic for debian 9.
Related to the DxfDecoder, the name can be changed in something else. It's not a decoder anymore. This was the first step, at that time a nice name.
One of the next things to write in C++ is a object move and rotate function. The rotate function is quite easy. The move function is quite easy too. The object move and rotation function is in fact a preprocess step of the auto nesting algoritme. A good practice for a lazy sunday. I don't think we can write the nesting algoritme in one lazy sunday... Haha..
![:woohoo: :woohoo:](/media/kunena/emoticons/w00t.png)
The rotate function is already used for drawing a polygone. The spline function we will not adapt coming time, i think this will take to much time to investegate. And a spline can be funest for Cam. Controlling a cad formed arc-strip can be a better option.
First finish the cad section, then update the cam section. Then provide a free cad/cam version. Must make a auto installer in the mean time too... Hmmm.. nice... I am no autodesk company... But almost looking at autodesk, one of the most richest company's ww. We have soon more exotic features then draftsight ( a autodesk product), i promise the linux users. Hhahahahaha. Just liking the way linux is going to defeat window's and autodesk in a few years from now.
For the cad section i will make also the following function's the coming time :
- snap to endpoint, midpoint, perpendicular intersection etc.
- trim and extend. ( extend a line without selecting a target is possible, this is also a new cad function )
- scale
- stretch
- fillet with radius
- fillet with ellipse (new, material reduction, perfect line's)
- chamfer corners
So a lot to do. But we have time. And it's not very difficult to code anymore. We know what we are doing bro...
Tonight I made some icon's with inkscape.. Inkscape is a nice free program !!!
Last edit: 14 Aug 2019 01:49 by Grotius.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
18 Aug 2019 18:24 - 18 Aug 2019 18:46 #142448
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,
For selecting lines and other item's that appear on the screen we had to implement the Opengl selection process.
This was not easy. After 2 day's it's working with a perfect accuracy.
First i tried the Opengl stensil procedure. This worked, but is limited to a buffer of 255 item's. This it's not enough when a drawing has 1000 lines of the same colour.
So we moved on to a glupickmatrix implementation. And this is working very accurate now after 2 day's of work. I had problem's
to solve with the int viewport[4]. It is solved by reading the glGetIntegerv(GL_VIEWPORT, viewport); outside the glRenderMode(GL_SELECT); mode. Conclusion : the int viewport[4] parameters in the select mode are a little different then in modelview mode. This difference is about 5 pixels. But is just enough to get less accuracy. This problem was hard to spot.
But we solved it.
The implementation work's with 3d selection.
Attached is a nice QT Cad template project for student's or prof's to start with.
It has a gui, a opengl interface. It's a very basic template without drawing function's etc.
It has a quick mouse drag function, mouse zoom function, mouse 3d rotate function and most important the mouse object select function.
Can someone test the compiled version please... It's attached as GrotiusCadCam_compiled.zip
To test the compiled version, unzip and type in terminal : ./GrotiusCadCam
Please let me know if it works without dependencies like Qt_opengl or something like that...
For selecting lines and other item's that appear on the screen we had to implement the Opengl selection process.
This was not easy. After 2 day's it's working with a perfect accuracy.
First i tried the Opengl stensil procedure. This worked, but is limited to a buffer of 255 item's. This it's not enough when a drawing has 1000 lines of the same colour.
So we moved on to a glupickmatrix implementation. And this is working very accurate now after 2 day's of work. I had problem's
to solve with the int viewport[4]. It is solved by reading the glGetIntegerv(GL_VIEWPORT, viewport); outside the glRenderMode(GL_SELECT); mode. Conclusion : the int viewport[4] parameters in the select mode are a little different then in modelview mode. This difference is about 5 pixels. But is just enough to get less accuracy. This problem was hard to spot.
But we solved it.
The implementation work's with 3d selection.
Attached is a nice QT Cad template project for student's or prof's to start with.
It has a gui, a opengl interface. It's a very basic template without drawing function's etc.
It has a quick mouse drag function, mouse zoom function, mouse 3d rotate function and most important the mouse object select function.
Can someone test the compiled version please... It's attached as GrotiusCadCam_compiled.zip
To test the compiled version, unzip and type in terminal : ./GrotiusCadCam
Please let me know if it works without dependencies like Qt_opengl or something like that...
Last edit: 18 Aug 2019 18:46 by Grotius.
The following user(s) said Thank You: phillc54, tommylight
Please Log in or Create an account to join the conversation.
- ftkalcevic
- Offline
- Junior Member
-
Less
More
- Posts: 33
- Thank you received: 4
18 Aug 2019 23:10 #142462
by ftkalcevic
Another nice thing about QT C++ is you can run it without the overhead of X11 running (mostly). This saves memory and CPU load, and annoying pop ups. X11 can always be launched from the command line if you need it.
Running from the text based console you can get QT to use the video card frame buffer directly by just placing some command line arguments...
There are limitations - most annoyingly, no opengl, which also means no qtquick (the last time I looked). This means no path preview.
I'm trying to fire up qtvcp to see it QtPy can support the framebuffer mode.
Replied by ftkalcevic on topic QT C++ code samples
Why post something about QT C++?
Another nice thing about QT C++ is you can run it without the overhead of X11 running (mostly). This saves memory and CPU load, and annoying pop ups. X11 can always be launched from the command line if you need it.
Running from the text based console you can get QT to use the video card frame buffer directly by just placing some command line arguments...
my_qt_app -platform linuxfb:fb="/dev/fb0"
There are limitations - most annoyingly, no opengl, which also means no qtquick (the last time I looked). This means no path preview.
I'm trying to fire up qtvcp to see it QtPy can support the framebuffer mode.
The following user(s) said Thank You: Grotius
Please Log in or Create an account to join the conversation.
21 Aug 2019 21:59 #142744
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,
A little project update.
Added a move function, did some object snap practice, and did improvements in program structure. If we do things wrong we
will end up with a slow cad cam program. But it's super fast until now. So that's a good sign for now. I am more and more confident we will make a very nice program... When the cad cam is ready, it can become a Draftsight replacer. How long will draftsight be free for linux?
I mentioned when drawing a line in drafsight, you can use the line icon, but you can use keyboard command's like : L + return for drawing a line.
In my cad version pressing the keyboard L button is enough to draw a line. The return has not to be used. This saves a keypress every time. User can switch between L ( line ) or M ( move ) without pressing the return or enter button.
Another item i mentioned is the move function in Draftsight. When using a move function with previous selection for example.
To move in Draftsight with keyboard buttons : M (move) + return -- then -- P (previous) + return. In my cad version you press M.
Then you can move the selected objects with mouse, when move is active user can add or remove selected objects to the move function.![B) B)](/media/kunena/emoticons/cool.png)
At the moment i am tuning and coding how to get a near perfect user interface... I have already done some snap functions. There is a lot to do.
A little project update.
Added a move function, did some object snap practice, and did improvements in program structure. If we do things wrong we
will end up with a slow cad cam program. But it's super fast until now. So that's a good sign for now. I am more and more confident we will make a very nice program... When the cad cam is ready, it can become a Draftsight replacer. How long will draftsight be free for linux?
I mentioned when drawing a line in drafsight, you can use the line icon, but you can use keyboard command's like : L + return for drawing a line.
In my cad version pressing the keyboard L button is enough to draw a line. The return has not to be used. This saves a keypress every time. User can switch between L ( line ) or M ( move ) without pressing the return or enter button.
Another item i mentioned is the move function in Draftsight. When using a move function with previous selection for example.
To move in Draftsight with keyboard buttons : M (move) + return -- then -- P (previous) + return. In my cad version you press M.
Then you can move the selected objects with mouse, when move is active user can add or remove selected objects to the move function.
![B) B)](/media/kunena/emoticons/cool.png)
At the moment i am tuning and coding how to get a near perfect user interface... I have already done some snap functions. There is a lot to do.
Attachments:
The following user(s) said Thank You: tommylight, Clive S
Please Log in or Create an account to join the conversation.
23 Aug 2019 23:17 - 23 Aug 2019 23:19 #143017
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,
It's going nice. We added a copy and rotate function to the cad interface. Now we have to integrate the mirror function.
The rotate function is done with the help of a matrix.
stackoverflow.com/questions/23856034/coo...r-rotation-in-opengl
| cos(25°) -sin(25°) 0 0 |
| sin(25°) cos(25°) 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
wich result in a c formula x' = cos(25°)*x -sin(25°)*y y' = sin(25°)*x +cos(25°)*y.
In the C++ program it's integrated like this :
x0 = cos(rotate_degrees * M_PI / 180.0 )* dist_x_startpoint - sin(rotate_degrees * M_PI / 180.0 ) * dist_y_startpoint;
y0 = sin(rotate_degrees * M_PI / 180.0 )* dist_x_startpoint + cos(rotate_degrees * M_PI / 180.0 ) * dist_y_startpoint;
x1 = cos(rotate_degrees * M_PI / 180.0 )* dist_x_endpoint - sin(rotate_degrees * M_PI / 180.0 ) * dist_y_endpoint;
y1 = sin(rotate_degrees * M_PI / 180.0 )* dist_x_endpoint + cos(rotate_degrees * M_PI / 180.0 ) * dist_y_endpoint;
A gif example how the program work's with object select, rotate, move and copy function's.
It's going nice. We added a copy and rotate function to the cad interface. Now we have to integrate the mirror function.
The rotate function is done with the help of a matrix.
stackoverflow.com/questions/23856034/coo...r-rotation-in-opengl
| cos(25°) -sin(25°) 0 0 |
| sin(25°) cos(25°) 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
wich result in a c formula x' = cos(25°)*x -sin(25°)*y y' = sin(25°)*x +cos(25°)*y.
In the C++ program it's integrated like this :
x0 = cos(rotate_degrees * M_PI / 180.0 )* dist_x_startpoint - sin(rotate_degrees * M_PI / 180.0 ) * dist_y_startpoint;
y0 = sin(rotate_degrees * M_PI / 180.0 )* dist_x_startpoint + cos(rotate_degrees * M_PI / 180.0 ) * dist_y_startpoint;
x1 = cos(rotate_degrees * M_PI / 180.0 )* dist_x_endpoint - sin(rotate_degrees * M_PI / 180.0 ) * dist_y_endpoint;
y1 = sin(rotate_degrees * M_PI / 180.0 )* dist_x_endpoint + cos(rotate_degrees * M_PI / 180.0 ) * dist_y_endpoint;
A gif example how the program work's with object select, rotate, move and copy function's.
Attachments:
Last edit: 23 Aug 2019 23:19 by Grotius.
Please Log in or Create an account to join the conversation.
24 Aug 2019 23:26 #143113
by Grotius
Replied by Grotius on topic QT C++ code samples
Thank you Tom, Clive and Phill !
Today added the stretch function and the scale function.
For the stretch function we had to make a window select option. This select window selects the point's in the window.
After that, a list is made for selected point's. After that there is a kind of move function to stretch the selected item's.
It's not hard to make a stretch function.
Next thing to do is fill the side screen tab page with parametric model function's.
I have to do research about writing text for dimension's in opengl. I would like a text wich is also suitable for cam.
stretch example :
scale example:
Today added the stretch function and the scale function.
For the stretch function we had to make a window select option. This select window selects the point's in the window.
After that, a list is made for selected point's. After that there is a kind of move function to stretch the selected item's.
It's not hard to make a stretch function.
Next thing to do is fill the side screen tab page with parametric model function's.
I have to do research about writing text for dimension's in opengl. I would like a text wich is also suitable for cam.
stretch example :
scale example:
Attachments:
The following user(s) said Thank You: phillc54, tommylight
Please Log in or Create an account to join the conversation.
26 Aug 2019 08:15 - 26 Aug 2019 08:23 #143197
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,
A little project update.
When a object is selected, we can edit the start and end points.
A nice feature is that we can edit the line lenght and edit the angle. This 2 function's are not editable in Draftsight.
The xy start, xy end coordinates are automaticly updated to line lenght and the line angle and visa versa.
A negative line lenght is also possible. Negative angle's are also possible.
Next thing to do is add a "new object" button to the parametric side menu. Then a drawing can made without using the mouse at all.
I will leave the @ command's for drawing a line. I think it's a bit outdated and also complex for new cad users.
A little project update.
When a object is selected, we can edit the start and end points.
A nice feature is that we can edit the line lenght and edit the angle. This 2 function's are not editable in Draftsight.
The xy start, xy end coordinates are automaticly updated to line lenght and the line angle and visa versa.
A negative line lenght is also possible. Negative angle's are also possible.
Next thing to do is add a "new object" button to the parametric side menu. Then a drawing can made without using the mouse at all.
I will leave the @ command's for drawing a line. I think it's a bit outdated and also complex for new cad users.
Attachments:
Last edit: 26 Aug 2019 08:23 by Grotius.
The following user(s) said Thank You: tommylight, Clive S
Please Log in or Create an account to join the conversation.
02 Oct 2019 19:13 - 02 Oct 2019 19:17 #146889
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,
Today i present a project update..
In the past weeks i had to solve a few problems related to the Cad side of the C++ program. There where big problem's
related to the visualisation of the screen and the select procedure.
- Problem 1 : Screen resize problem's. Some people name it aspect or ratio. I spotted problem's with zoom function's. For example a circle was viewed almost as a ellipse when certain zoom's where done. So i did a code rewrite for this item from scratch several time's in several way's. The final zoom code is working as should be.
- Problem 2 : Object select methode by mouse pointer. When the user has made a drawing, the user can select line's when user click's on the line. For cad it's usual that a line, circle or arc light's up when mouse pointer is within a close area.
OpenGL has different implementation's for this object select methode. I tried them all. The conclusion is, non of them works fast
when a drawing has 20.000 lines, circles, arc's or more. So that is not good !
The solution was to write C++ code from scratch to do a object select for a line, circle and arc. A visualisation of the select methode (find intersection) is attached. I found out this is a very accurate methode to find intersections, nearest's etc.
The example show's how to find a circle intersection point by mouse pointer.
For line and arc intersections, the C++ code is almost the same.
First we look at 1. find a circle that is close to the mouse pointer, for example a mouse pointer with 1mm radius.
After that we do 2. We calculate the line-circle intersection and find the closest of 2 output's, and done !
Finally the Cad program is zooming very nice. A circle is a circle in all circumstances.
Also the mouse select methode is very fast for big drawings (20.000 item's plus).
The planning is to integrate all existing functions that where made and tested in the past.
Functions to integrate now are for example : draw line, arc, circle, polygon etc. move, mirror. copy etc.
At the moment the Goal is that this program can be competitive to autocad some day.
This program has a integrated Cam module what is resulting in less programming step's for the end user. Developing
auto nesting after the first CAD-CAM version is released, is on my bucket list.
Dxf example to test the program for dxf read in, speed, zoom function's, object select function's etc.
Today i present a project update..
In the past weeks i had to solve a few problems related to the Cad side of the C++ program. There where big problem's
related to the visualisation of the screen and the select procedure.
- Problem 1 : Screen resize problem's. Some people name it aspect or ratio. I spotted problem's with zoom function's. For example a circle was viewed almost as a ellipse when certain zoom's where done. So i did a code rewrite for this item from scratch several time's in several way's. The final zoom code is working as should be.
- Problem 2 : Object select methode by mouse pointer. When the user has made a drawing, the user can select line's when user click's on the line. For cad it's usual that a line, circle or arc light's up when mouse pointer is within a close area.
OpenGL has different implementation's for this object select methode. I tried them all. The conclusion is, non of them works fast
when a drawing has 20.000 lines, circles, arc's or more. So that is not good !
The solution was to write C++ code from scratch to do a object select for a line, circle and arc. A visualisation of the select methode (find intersection) is attached. I found out this is a very accurate methode to find intersections, nearest's etc.
The example show's how to find a circle intersection point by mouse pointer.
For line and arc intersections, the C++ code is almost the same.
First we look at 1. find a circle that is close to the mouse pointer, for example a mouse pointer with 1mm radius.
After that we do 2. We calculate the line-circle intersection and find the closest of 2 output's, and done !
Finally the Cad program is zooming very nice. A circle is a circle in all circumstances.
Also the mouse select methode is very fast for big drawings (20.000 item's plus).
The planning is to integrate all existing functions that where made and tested in the past.
Functions to integrate now are for example : draw line, arc, circle, polygon etc. move, mirror. copy etc.
At the moment the Goal is that this program can be competitive to autocad some day.
This program has a integrated Cam module what is resulting in less programming step's for the end user. Developing
auto nesting after the first CAD-CAM version is released, is on my bucket list.
Dxf example to test the program for dxf read in, speed, zoom function's, object select function's etc.
Last edit: 02 Oct 2019 19:17 by Grotius.
Please Log in or Create an account to join the conversation.
Time to create page: 1.773 seconds