What really is a QPolygon...
Suppose the following code I supposed to do a union of polyogn
Code:
f<<QPointF(1,1)<<QPointF(10,29);
g<<QPointF(100,100)<<QPointF(10,290);
qSort(f.begin(),f.end(),lessThanPoint);
qSort(g.begin(),g.end(),lessThanPoint);
qDebug()<< f.united(g);
Why I get the following result:
QPolygonF(QPointF(1, 1)QPointF(1, 1)QPointF(10, 29)QPointF(1, 1)QPointF(10, 290)QPointF(100, 100)QPointF(10, 290)QPointF(1, 1))
:confused:
I should have simply the union of the point (a polygon of 4 points).
Maybe I am missing something?
G
Re: What really is a QPolygon...
Re: What really is a QPolygon...
I do not understand.
Actually, I wanna perform a merging of two curve obatained from two data set.
But: during the merging I would keep only those points who are the highest (I am supposing to draw the polygons on an xy plane).
There is a simple way in qt to merge two curves in this way?
G
Re: What really is a QPolygon...
Simply draw them both. One will cover the other and you will get what you wanted.
Re: What really is a QPolygon...
Yes, you're right. I should study more...
Anyway, if the polygons really represent curve, I have to dela with extremes...
Code:
{
p1.
prepend(QPointF(serie1.
first().
x(),
0));
p1.
append(QPointF(serie1.
last().
x(),
0));
p2.
prepend(QPointF(serie2.
first().
x(),
0));
p2.
append(QPointF(serie2.
last().
x(),
0));
qSort(temp.begin(),temp.end(),lessThanPoint);
first = temp.first();
last = temp.last();
t.resize(t.size()-2);
t.append(last);
return t;
}
1 Attachment(s)
Re: What really is a QPolygon...
I am quite stucked at this problem...the previous code does not work.
The problem is depicted in the figure.
There is a way to merge two curves or polygon and picks the envelope?
Regards
Re: What really is a QPolygon...
It's not an easy math problem so I wouldn't expect there to be a ready function for it in Qt.
Re: What really is a QPolygon...
Actually, the union of polygons works quite well with QPOlygonF::united(), and
I expected that a similar function was available also for polylines.
The problem is that after the union, the points are not ordered in the right way....
It should be enough to have a way to open the polygon, i.e. eliminating the segment which lies on the x axis....:crying:
Re: What really is a QPolygon...
Have you tried using QPainterPath? Maybe you'll have more luck with it.
Re: What really is a QPolygon...
I have no idea at all how to use it.
If you some suggestion, I will appreciate very much....
G
Re: What really is a QPolygon...
Add primitives to it. You can also unite it. There is a paragraph in the reference (Composing a QPainterPath) that might be helpful.
Re: What really is a QPolygon...
I tried, but the problem is always the same.
After the union of paths, the points order is arbitary and for this reason is quite difficult to convert the path to a curve in the 2D-plane.
(For instance, the union of Polygons use the united function of QPainterPath).
G