Creating a new drawing device based on QPaintEngine + QPaintDevice ...
-
@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.
-
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.
Good day !
Ooo! Thank you so much for the tip on the options for counseling ! I will try ...
As for debugging the code and getting a clearer picture of how Qt classes work - yes , of course ! That 's what I 'm doing ! But so far the results are insignificant ! :)
But in any case - thank you for your advice !!!
Sincerely, Yuri.
-
Good day !
And so ! :)
Part of my weekend was devoted to trying to solve my puzzle ! :)As a result :
-
it is clear that SVG prevents my code from converting files - this is transform="translate(... ...)" ! Files where there are no transformations , as they were the success that I had from the very beginning ! :)
But I am absolutely sure that this is just because I use the methods of the Qt Paint System classes poorly ! Since when working with , for example , QImage , the same files are drawn perfectly !
I became even more convinced that it is necessary to seek competent help from specialists who work with SVG and can advise on the methods of the Qt Paint System classes or understand the source code. :))) -
I looked very carefully at the ICS resource! Judging by the information on their website, they are just VERY competent in Qt (just cool)! And of course I wrote to them ! I even signed up for a free QML course :), but unfortunately I have not yet received an answer both to the desire to learn from them and to the question I asked! I'll be waiting...
-
And finally - special thanks to SGaist - for advising me the ICS resource! And in general for the reaction to my questions ! :)
Sincerely, Yuri.
-
-
Good day !
Can one of my colleagues tell me how to properly overload the methods virtual void QPaintEngine::updateState(const QPaintEngineState &state) and virtual int QPaintDevice::metric(PaintDeviceMetric metric) const ?
Or where can I see examples of their overload ?
Sincerely, Yuri.
-
Good day !
Can one of my colleagues tell me how to properly overload the methods virtual void QPaintEngine::updateState(const QPaintEngineState &state) and virtual int QPaintDevice::metric(PaintDeviceMetric metric) const ?
Or where can I see examples of their overload ?
Sincerely, Yuri.
@Yuri34 said in Creating a new drawing device based on QPaintEngine + QPaintDevice ...:
properly overload the methods
Do you mean overload? Overload means write a new version of the
QPaintEngine::updateState()
method which takes different parameters from the current one. In which case you just write that. Is this what you want?Or did you mean override instead? Override means write your own version of the existing virtual methods with the same parameters as the existing one. Is that actually what you want? In which case:
// in yourclass.h class YourClass : public QPaintEngine { virtual void updateState(const QPaintEngineState &state) override; } // in yourclass.cpp void YourClass::updateState(const QPaintEngineState &state) { ... // and if you need to call the original base class implementation QPaintEngine::updateState(state); ... }
-
Oh, thanks !
Apparently I explained it incorrectly ! :)
What is overloading and how syntactically it is formed in c++/Qt, I perfectly imagine!
I am interested in what and what is initialized in the virtual methods I mentioned ?In order not to insert pieces of code here, I will mention once again the link to the repo-gitlab - https://gitlab.com/z34x/codemaker.git !
- ::metric() at the end of the file - FCPaintDevice
- ::updateState() at the end of the file - FCPaintEngine
I 'm doing exactly wrong !!!
My question is how to properly design these virtual methods so that the svg file is parsed correctly ? :)
Moreover, pay attention to the virtual void QPaintEngine::updateState(const QPaintEngine State &state) = 0 ! abstract method !!!
Sincerely, Yuri.
-
I have one more question ! :)
Who knows how the QPaintDevice scaling system works ?
It is the theory that interests me !
I don't understand what needs to be done to implement full-fledged scaling except overloading and implementing my own instance of QPaintDevice::metric(..) !Best regards, Yuri.
-
Good afternoon!
Who can help with understanding how to work with QPaintDevice::metric(..) ?
I have already read and tried everything that is written in the documentation, of course ! :)- QPaintDevice::PdmWidth: - width in svg storage units; (as far as I understand in pixels) (we take from QSvgRenderer::defaultDevice(..))
- QPaintDevice::PdmHeight: - height similarly
- QPaintDevice::PdmWidthMM: - width in mm (we take from QSvgRenderer::viewBox(..))
- QPaintDevice::PdmHeightMM: - height is similar
- QPaintDevice::PdmNumColors: - the number of colors for the device being created (a constant from the device requirements) - let it be, for example, 16
- QPaintDevice::PdmDepth: - the number of bit planes (by docks) - it's not clear here - it's a bit per color or something Incomprehensible
- QPaintDevice::PdmDpiX: - dpi X logical - it's not clear to me here!!!
- QPaintDevice::PdmPhysicalDpiX: - dpi X physical - similarly!!!
- QPaintDevice::PdmDpiY: - dpi Y logical - similar !!!
- QPaintDevice::PdmPhysicalDpiY: - dpi Y physical - similar !!!
- QPaintDevice::pdmdevicepixelratio: - the ratio of what to what is Incomprehensible
- QPaintDevice::PdmDevicePixelRatioScaled: - similar!!!
I 'm sure I don 't understand the idea that is embedded in class management ! If someone has experience working with this method and , accordingly, with the class , I will be very grateful for any hints !
Sincerely, Yuri.
PS: It is clear that you can write your crutches to this class and make it generate what you need ! But I would like to understand exactly the logic that the developers laid down.