Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Creating a new drawing device based on QPaintEngine + QPaintDevice ...
Forum Updated to NodeBB v4.3 + New Features

Creating a new drawing device based on QPaintEngine + QPaintDevice ...

Scheduled Pinned Locked Moved Unsolved General and Desktop
30 Posts 5 Posters 3.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mchinand
    wrote on last edited by
    #17

    @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?

    1 Reply Last reply
    0
    • Yuri34Y Yuri34

      @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.

      M Offline
      M Offline
      mchinand
      wrote on last edited by mchinand
      #18

      @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 pixels whereas g-code describes how the tooling (3D printer, CNC, etc. ) should move and is more akin to a vector graphics format.

      Yuri34Y 1 Reply Last reply
      0
      • M mchinand

        @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 pixels whereas g-code describes how the tooling (3D printer, CNC, etc. ) should move and is more akin to a vector graphics format.

        Yuri34Y Offline
        Yuri34Y Offline
        Yuri34
        wrote on last edited by
        #19

        @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 :

        1. 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 :)))

        2. 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.

        1 Reply Last reply
        1
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #20

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          Yuri34Y 1 Reply Last reply
          0
          • SGaistS SGaist

            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.

            Yuri34Y Offline
            Yuri34Y Offline
            Yuri34
            wrote on last edited by
            #21

            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.

            1 Reply Last reply
            0
            • Yuri34Y Offline
              Yuri34Y Offline
              Yuri34
              wrote on last edited by
              #22

              Good day !

              And so ! :)
              Part of my weekend was devoted to trying to solve my puzzle ! :)

              As a result :

              1. 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. :)))

              2. 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...

              3. And finally - special thanks to SGaist - for advising me the ICS resource! And in general for the reaction to my questions ! :)

              Sincerely, Yuri.

              1 Reply Last reply
              0
              • Yuri34Y Offline
                Yuri34Y Offline
                Yuri34
                wrote on last edited by Yuri34
                #23

                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.

                JonBJ 1 Reply Last reply
                0
                • Yuri34Y Yuri34

                  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.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #24

                  @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);
                      ...
                  }
                  
                  1 Reply Last reply
                  0
                  • Yuri34Y Offline
                    Yuri34Y Offline
                    Yuri34
                    wrote on last edited by Yuri34
                    #25

                    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.

                    1 Reply Last reply
                    0
                    • Yuri34Y Offline
                      Yuri34Y Offline
                      Yuri34
                      wrote on last edited by
                      #26

                      Good day !

                      Ooook ! :)
                      It seems like the problem is not frequent for developers or not relevant !

                      Best regards, Yuri.

                      1 Reply Last reply
                      0
                      • Yuri34Y Offline
                        Yuri34Y Offline
                        Yuri34
                        wrote on last edited by
                        #27

                        The next question ...

                        Is there a method in the Qt Painting System classes that allows you to determine the intersection of primitives when drawing on QPaintDevice ?

                        Best regards, Yuri.

                        1 Reply Last reply
                        0
                        • Yuri34Y Offline
                          Yuri34Y Offline
                          Yuri34
                          wrote on last edited by
                          #28

                          OooK!
                          I'll answer myself (maybe it's interesting to someone besides me) !
                          Of course there is - intersect(..)/intersected(..) !!!

                          Best regards, Yuri.

                          1 Reply Last reply
                          0
                          • Yuri34Y Offline
                            Yuri34Y Offline
                            Yuri34
                            wrote on last edited by
                            #29

                            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.

                            1 Reply Last reply
                            0
                            • Yuri34Y Offline
                              Yuri34Y Offline
                              Yuri34
                              wrote on last edited by
                              #30

                              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.

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved