Curve Manager from a list of Points
-
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
-
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...
-
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 ....
-
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 segmentand 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.
-
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?