Creating a new drawing device based on QPaintEngine + QPaintDevice ...
-
Good afternoon colleagues !
There is a need to create a class of a new drawing device similar to QWidget, QPrinter, ... !
The goal is to write a class that will allow you to load svg into it and generate lists of primitives QPainterPath::ElementType:: at the output... to convert them to g-code!
I understand that this is the interaction of the QPaint + QPaintEngine + QPaintDevice classes ! But the question is precisely in the nuances of interaction and implementation !Who has experience writing such classes ? We need consultations on the course of implementation !
Sincerely, Yuri.
-
Hi,
Did you consider the Qt Svg module as a starting point ?
-
-
That I understood, I was thinking of the use of the parser to get the data you want.
-
Good afternoon!
After a little digging, I got this sketch - https://gitlab.com/z34x/codemaker.git
Something certainly turned out ! But there are no fewer questions :) !
And so :
1 I understand that inheritance should be something like this.
2 I understand that the use of objects of the successor classes QPaintDevice, QPaintEngine and QPainter should happen like this.3 I don 't understand how to set linear dimensions to the heir of QPaintDevice ! It would be logical that it would be the successor of QPaintDevice that would have virtual methods with which the parameters of the device to which the output occurs are changed (linear dimensions, units of measurement ...)! But I understand that my logic here conflicts with reality. :)
4. I don't understand what to do in the begin() and end() methods when inheriting, for example, the QPaintDevice class. :)That's what I want to say - sign me up for courses on Qt :)))) ! Well , or explain to the ignorant ...
Unfortunately, I have not found a solution to such a problem on the web, but I really want to learn how to write device classes! :)Well, as a consequence, I manage to convert one of the svg files that is in the /in subdirectory and its converted image to /out! It's called Petya.svg! But it is not possible to convert the rest ! The reason is clear to me in the rest there is a g< > tag ! But how to solve this problem is not clear ! :)
In short , there are many questions ...
Sincerely, Yuri.
-
Just to get thing correctly, you want to program a CNC out of a SVG file ?
In that case, why create a new painting system ? It seems to me that you should parse the svg and convert it to g-code directly rather than trying to "paint" g-code. Maybe I missed something though.
-
Good day !
Yes! That 's about how it is !
It 's really CNC !
Parsing and converting to g-code is what I can do now! I 'm interested in doing it in the Qt style ! If you look carefully , all the stages of conversion to Qt are already being done ! It is only necessary to understand and correctly formalize the interaction of class objects !
This is exactly my task !
Since I want to learn how to write output devices based on QPaintDevice !Sincerely, Yuri.
-
Unfortunately, Qt specialists do not advise on the use of their classes in open source projects (or I am not aware of this)! I would be very grateful if you would recommend a person to whom I could address my questions privately ! Naturally, I am ready to compensate for the time spent on me with payment! :)
Sincerely, Yuri.
-
Did you look at the SVG module (the source code, not just the classes and their methods) like @SGaist recommended? That takes an SVG file and ultimately draws it to the screen. I don't know the details of its implementation, it might already do pretty close to what you want.
-
Unfortunately, Qt specialists do not advise on the use of their classes in open source projects (or I am not aware of this)! I would be very grateful if you would recommend a person to whom I could address my questions privately ! Naturally, I am ready to compensate for the time spent on me with payment! :)
Sincerely, Yuri.
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
Unfortunately, Qt specialists do not advise on the use of their classes in open source projects (or I am not aware of this)!
I am not following you on this one. Can you clarify ?
-
Did you look at the SVG module (the source code, not just the classes and their methods) like @SGaist recommended? That takes an SVG file and ultimately draws it to the screen. I don't know the details of its implementation, it might already do pretty close to what you want.
@mchinand said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
Did you look at the SVG module (the source code, not just the classes and their methods) like @SGaist recommended? That takes an SVG file and ultimately draws it to the screen. I don't know the details of its implementation, it might already do pretty close to what you want.
Good day !
Of course I watched and continue to watch , but unfortunately I haven 't found anything that would answer my questions yet !
Sincerely, Yuri.
-
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
Unfortunately, Qt specialists do not advise on the use of their classes in open source projects (or I am not aware of this)!
I am not following you on this one. Can you clarify ?
@SGaist said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
Unfortunately, Qt specialists do not advise on the use of their classes in open source projects (or I am not aware of this)!
I am not following you on this one. Can you clarify ?
Of course!
I meant that I still could not find a high - quality consultation option from Qt ! If I didn 't buy a professional developer license !
My efforts have not yet yielded the necessary result because I do not have enough knowledge in the nuances of working with Qt classes ! In parallel, I continue to try to solve my problem, I try to gain experience in Qt and I am looking for a person who could advise me qualitatively!Sincerely, Yuri.
-
@SGaist said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
Unfortunately, Qt specialists do not advise on the use of their classes in open source projects (or I am not aware of this)!
I am not following you on this one. Can you clarify ?
Of course!
I meant that I still could not find a high - quality consultation option from Qt ! If I didn 't buy a professional developer license !
My efforts have not yet yielded the necessary result because I do not have enough knowledge in the nuances of working with Qt classes ! In parallel, I continue to try to solve my problem, I try to gain experience in Qt and I am looking for a person who could advise me qualitatively!Sincerely, Yuri.
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
high - quality consultation option from Qt
You expect to get this for free?
Here you are in a user forum. Most people here do not work for Qt Company and help others in their own time... -
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
high - quality consultation option from Qt
You expect to get this for free?
Here you are in a user forum. Most people here do not work for Qt Company and help others in their own time...@jsulm said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
You expect to get this for free?
Here you are in a user forum. Most people here do not work for Qt Company and help others in their own time...:) no!
I don't expect to be consulted for free !
Like all open sources , I understand by reading information on this forum and on many other specialized forums ! Through communication and knowledge sharing !
As for the specific problem with solving my task, I am ready to pay (within reasonable limits) for the consultant's efforts!
If my proposal violates the rules of the forum - please forgive me !
I will not make such statements here anymore !Sincerely, Yuri.
-
@jsulm said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
You expect to get this for free?
Here you are in a user forum. Most people here do not work for Qt Company and help others in their own time...:) no!
I don't expect to be consulted for free !
Like all open sources , I understand by reading information on this forum and on many other specialized forums ! Through communication and knowledge sharing !
As for the specific problem with solving my task, I am ready to pay (within reasonable limits) for the consultant's efforts!
If my proposal violates the rules of the forum - please forgive me !
I will not make such statements here anymore !Sincerely, Yuri.
-
@jsulm said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
OK, I understand. It is perfectly fine to ask for paid support here I think.
Ok ! Thanks !
I am glad that we understand each other !But I would also like to sort out my task ! :)
At the moment there are 2 files : piter.svg and rose.svg from my set of files that are somehow converted by my code and there are many other files that I can't convert with the same code! I 'm doing something wrong and I really want to understand what exactly ! :)And that 's not even the most important thing ! I want to figure out in general how to write devices based on QPaintDevice correctly! :)
Sincerely, Yuri.
-
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
At the moment there are 2 files : piter.svg and rose.svg from my set of files that are somehow converted by my code and there are many other files that I can't convert with the same code
I would look at the similarities between your two working files compared to your other SVGs. For example, do the non-working files use an SVG feature (e.g., text) that the working ones do not? Does your program crash with the other files or just not generate the correct output?
-
@jsulm said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
OK, I understand. It is perfectly fine to ask for paid support here I think.
Ok ! Thanks !
I am glad that we understand each other !But I would also like to sort out my task ! :)
At the moment there are 2 files : piter.svg and rose.svg from my set of files that are somehow converted by my code and there are many other files that I can't convert with the same code! I 'm doing something wrong and I really want to understand what exactly ! :)And that 's not even the most important thing ! I want to figure out in general how to write devices based on QPaintDevice correctly! :)
Sincerely, Yuri.
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
I want to figure out in general how to write devices based on QPaintDevice correctly
If this is your goal, that's fine but does not seem like it is something that would be useful for generating g-code.
A QPaintDevice consists of pixelswhereas g-code describes how the tooling (3D printer, CNC, etc. ) should move and is more akin to a vector graphics format. -
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
I want to figure out in general how to write devices based on QPaintDevice correctly
If this is your goal, that's fine but does not seem like it is something that would be useful for generating g-code.
A QPaintDevice consists of pixelswhereas g-code describes how the tooling (3D printer, CNC, etc. ) should move and is more akin to a vector graphics format.@mchinand said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
I want to figure out in general how to write devices based on QPaintDevice correctly
If this is your goal, ...
I will try to answer you on points :
-
Of course! I'm analyzing the target svg files, but I don't understand what exactly is causing the problem yet ! But I 'm still doing it !
No! No critical failure occurs - just the code is not generated and that 's it ! If there was a critical failure , that would be my problem ! :) Although it doesn 't make it any easier ! The problem is still mine - I understand perfectly well that it's my misunderstanding of the nuances of the work of the three classes of Paint System :))) -
I'm sorry! But about QPaintDevice you seem to be mistaken ! This class is quite versatile ! And it allows you to draw on yourself not only pixel graphics , which is directly written in the documentation ! :)
Well , in the end , I still get something ! :)
Sincerely, Yuri.
-
-
Since you have working and non working files you should implement some sort of dump method that is verbose enough to show what happens and where things get wrong.
As for paid support, beside the Qt Company itself, you have enterprises like KDAB and ICS that are known to be very good.