Fixed method CheckLoops.

--HG--
branch : feature
This commit is contained in:
dismine 2014-01-13 00:34:36 +02:00
parent aa4feb648a
commit 1cffddc672
3 changed files with 27 additions and 31 deletions

View File

@ -241,22 +241,22 @@ QVector<QPointF> VContainer::CorrectEquidistantPoints(const QVector<QPointF> &po
correctPoints.append(points.at(i));
}
}
// if(correctPoints.size()<3)
// {
// return correctPoints;
// }
// //Remove point on line
// QPointF point;
// for(qint32 i = 1; i <correctPoints.size()-1; ++i)
// {
// QLineF l1(correctPoints[i-1], correctPoints[i]);
// QLineF l2(correctPoints[i], correctPoints[i+1]);
// QLineF::IntersectType intersect = l1.intersect(l2, &point);
// if (intersect == QLineF::NoIntersection)
// {
// correctPoints.remove(i);
// }
// }
if(correctPoints.size()<3)
{
return correctPoints;
}
//Remove point on line
QPointF point;
for(qint32 i = 1; i <correctPoints.size()-1; ++i)
{
QLineF l1(correctPoints[i-1], correctPoints[i]);
QLineF l2(correctPoints[i], correctPoints[i+1]);
QLineF::IntersectType intersect = l1.intersect(l2, &point);
if (intersect == QLineF::NoIntersection)
{
correctPoints.remove(i);
}
}
return correctPoints;
}
@ -579,7 +579,6 @@ QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points) const
/*We found loop.*/
ekvPoints.append(points.at(i));
ekvPoints.append(crosPoint);
ekvPoints.append(points.at(j+1));
i = j + 2;
}
}

View File

@ -251,24 +251,21 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const
QGraphicsScene *sc = this->scene();
QRectF rect = sc->itemsBoundingRect();
//Correct BoundingRect
rect = QRectF(0, 0, rect.width() + rect.x(), rect.height() + rect.y());
//rect = QRectF(0, 0, rect.width() + rect.x(), rect.height() + rect.y());
qDebug()<<"rect"<<rect;
QList<QGraphicsView*> list = sc->views();
QRect rec = list[0]->contentsRect();
qDebug()<<"rec"<<rec;
QTransform t = list[0]->transform();
qDebug()<<"m11="<<t.m11();
qDebug()<<"m22="<<t.m22();
//Correct contentsRect
rec = QRect(0, 0, rec.width() - rec.x(), rec.height() - rec.y());
if(rec.contains(rect.toRect()))
{
rec = QRect(0, 0, rec.width()/t.m11() - rec.x(), rec.height()/t.m22() - rec.y());
// rec = QRectF(rec.x()/t.m11(), rec.y()/t.m22(), rec.width()/t.m11(), rec.height()/t.m22());
qDebug()<<"rec"<<rec;
rec = rec.united(rect.toRect());
qDebug()<<"rec1"<<rec;
sc->setSceneRect(rec);
}
else
{
rect = rect.united(rec);
sc->setSceneRect(rect);
}
doc->haveLiteChange();
}