Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Curve Manager from a list of Points
QtWS25 Last Chance

Curve Manager from a list of Points

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 2 Posters 2.4k Views
  • 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.
  • S Offline
    S Offline
    Sil20
    wrote on 7 Mar 2013, 07:37 last edited by
    #1

    Hi,
    I am using now QT5.01, and Qtquick2.0.
    I was wondering if someone already developpe a Curve Manager for this? diplaying lists of points, scrolling in the curve, adding and removing point...

    Before with Qt4 Quick1.1, I modify a Canvas plugin to be abble to render curve and adding points to the curve. But now the Canvas is a native Qt itemis more complicated

    1 Reply Last reply
    0
    • U Offline
      U Offline
      utcenter
      wrote on 7 Mar 2013, 09:43 last edited by
      #2

      Not aware of the existence of such a component.

      Keep in mind that the typical approach to do this won't be a list of points, but a list of linear, cubic and quadratic curves with their control points. In a plain list of points it is not possible to determine how to interpret a point...

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sil20
        wrote on 7 Mar 2013, 09:48 last edited by
        #3

        yes, but when you whant to display some curve, maybe like values from recordings you do not really care about the interpolation, you just want to see straight line from one point to the next.

        for sure this kind of manager could be set with a parameter to choose between straight, lineare, quadric ....

        1 Reply Last reply
        0
        • U Offline
          U Offline
          utcenter
          wrote on 7 Mar 2013, 09:51 last edited by
          #4

          If all segments are the same, then it is OK, you just interpret each point the same way. But if you have a curve that is the combination of linear, cubic and quadratic segments this is not possible, since a linear curve only uses 2 points, a cubic uses 3 and a quadratic uses 4. You can still specify it manually but in order for this specification to be preserved you must export more than a list of points. You need to export the type of curve too.

          Your format needs to be something like:
          1 - integer that signifies the total number of segments
          2 - integer that signifies the type of the first segment, linear, quad, cubic, arc, move and so forth
          3 - a list of points for the particular segment
          4 - integer that signifies the type of the first segment, linear, quad, cubic, arc, move and so forth
          5 - a list of points for the particular segment

          and so on...

          Plus you will actually need to implement the actual QML component to do the drawing. Either a QQuickPaintedItem with QPainter, which is pretty straightforward and easy, or a QQuickItem and a custom geometry node, which requires to triangulate your curves and create the appropriate vertexes. QPainter on a OpenGL surface will do that for you behind the scenes.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sil20
            wrote on 7 Mar 2013, 09:54 last edited by
            #5

            Ok, but that is not my point. I want to be able to draw curves in ma application just lik Excel would do. Maybe a little better.

            1 Reply Last reply
            0
            • U Offline
              U Offline
              utcenter
              wrote on 7 Mar 2013, 10:03 last edited by
              #6

              I don't think this functionality exist out of the box, so you will have to implement it yourself...

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Sil20
                wrote on 7 Mar 2013, 12:13 last edited by
                #7

                That is what I thought.

                I already made a plugin that mage lists of points. I would like to implement the drawing of this point.
                I think I could use a Cavans item AND my Recorder like this.
                @ Canvas {
                id:canvas
                width: parent.width-5
                height: parent.height-5
                property var ctx: null;
                onPaint:{
                console.log("onpaint")
                ctx = canvas.getContext('2d');
                ctx.strokeStyle = Qt.rgba(0, 0, 0, 1);
                ctx.lineWidth = 1;
                ctx.beginPath();
                ctx.moveTo(20, 0);//start point
                ctx.bezierCurveTo(-10, 90, 210, 90, 180, 0);
                ctx.stroke();
                }
                }

                SdcnRecorder
                {
                id: iRecorder
                onInit:{
                addChartDataSet("chart1","black",2);
                addChartDataSet("chart2","red",2);
                }

                 Timer {
                     //interval: 2000; running: mbTimerRunning; repeat: true
                     interval: 200; running: true; repeat: true
                     onTriggered:
                     {
                
                         iRecorder.addPoint("chart1",10,2);
                         iRecorder.addPoint("chart2",20,2);
                         iRecorder.drawCharts(2);
                         iRecorder.drawCharts(canvas.ctx,2);
                     }
                 }/**/
                

                }@

                So the Context2D would be transmeted to my plugin for drawing this way my plugin could draw anywhere and several time the same data.
                But I cannot find what header to include in my plugin to access the Context2D method??
                Anyone has an idea?

                1 Reply Last reply
                0
                • U Offline
                  U Offline
                  utcenter
                  wrote on 7 Mar 2013, 13:24 last edited by
                  #8

                  If you don't need your curves to be clickable and manipulable you could use a canvas.

                  1 Reply Last reply
                  0

                  4/8

                  7 Mar 2013, 09:51

                  • Login

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