Fixes for method Mirror and debug system.

--HG--
branch : feature
This commit is contained in:
dismine 2015-01-17 19:23:54 +02:00
parent 1d1ae1acb4
commit 696aaa413b
2 changed files with 20 additions and 16 deletions

View File

@ -153,14 +153,24 @@ void VLayoutDetail::Mirror(const QLineF &edge)
return; return;
} }
const QLineF axis = QLineF(edge.x1(), edge.y1(), 100, edge.y2()); // Ox axis const QLineF axis = QLineF(edge.x2(), edge.y2(), edge.x2() + 100, edge.y2()); // Ox axis
const qreal angle = edge.angleTo(axis); const qreal angle = edge.angleTo(axis);
QMatrix m; QMatrix m;
m.translate(edge.p2().x(), edge.p2().y()); m.translate(edge.p2().x(), edge.p2().y());
m.rotate(-angle); m.rotate(-angle);
m.translate(-edge.p2().x(), -edge.p2().y());
d->matrix *= m;
m.reset();
m.translate(edge.p2().x(), edge.p2().y());
m.scale(m.m11(), m.m22()*-1); m.scale(m.m11(), m.m22()*-1);
m.rotate(360 - (-angle)); m.translate(-edge.p2().x(), -edge.p2().y());
d->matrix *= m;
m.reset();
m.translate(edge.p2().x(), edge.p2().y());
m.rotate(-(360-angle));
m.translate(-edge.p2().x(), -edge.p2().y()); m.translate(-edge.p2().x(), -edge.p2().y());
d->matrix *= m; d->matrix *= m;
} }

View File

@ -260,7 +260,7 @@ bool VLayoutPaper::AddToBlankSheet(const VLayoutDetail &detail, bool &stop)
} }
d->frame = d->frame + 2; d->frame = d->frame + 2;
for (int angle = 0; angle <= 360; ++angle) for (int angle = 0; angle <= 360; angle = angle+5)
{ {
QCoreApplication::processEvents(); QCoreApplication::processEvents();
@ -319,12 +319,8 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop)
bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, dEdge, bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, dEdge,
workDetail.GetMatrix()); workDetail.GetMatrix());
} }
else
{
continue; // Outside of sheet.
} }
} d->frame = d->frame + 2;
++d->frame;
} }
} }
@ -582,8 +578,6 @@ void VLayoutPaper::CombineEdges(VLayoutDetail &detail, const QLineF &globalEdge,
const qreal dx = globalEdge.x2() - detailEdge.x2(); const qreal dx = globalEdge.x2() - detailEdge.x2();
const qreal dy = globalEdge.y2() - detailEdge.y2(); const qreal dy = globalEdge.y2() - detailEdge.y2();
// detailEdge = QLineF(detailEdge.x1()+dx, detailEdge.y1()+dy, detailEdge.x2()+dx, detailEdge.y2()+dy);
// angle = detailEdge.angle();
detailEdge.translate(dx, dy); // Use values for translate detail edge. detailEdge.translate(dx, dy); // Use values for translate detail edge.
const qreal angle_between = globalEdge.angleTo(detailEdge); // Seek angle between two edges. const qreal angle_between = globalEdge.angleTo(detailEdge); // Seek angle between two edges.
@ -810,38 +804,38 @@ bool VLayoutPaper::SaveResult(const BestResult &bestResult, const VLayoutDetail
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPaper::DrawDebug(const VLayoutDetail &detail, int frame) const void VLayoutPaper::DrawDebug(const VLayoutDetail &detail, int frame) const
{ {
QImage frameImage(d->paperWidth*3, d->paperHeight*3, QImage::Format_RGB32); QImage frameImage(d->paperWidth*2, d->paperHeight*2, QImage::Format_RGB32);
frameImage.fill(Qt::white); frameImage.fill(Qt::white);
QPainter paint; QPainter paint;
paint.begin(&frameImage); paint.begin(&frameImage);
paint.setPen(QPen(Qt::darkRed, 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); paint.setPen(QPen(Qt::darkRed, 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
paint.drawRect(QRectF(d->paperWidth, d->paperHeight, d->paperWidth, d->paperHeight)); paint.drawRect(QRectF(d->paperWidth/2, d->paperHeight/2, d->paperWidth, d->paperHeight));
paint.setPen(QPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); paint.setPen(QPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
QPainterPath p; QPainterPath p;
if (d->globalContour.isEmpty()) if (d->globalContour.isEmpty())
{ {
p = DrawContour(CutEdge(QLineF(0, 0, d->paperWidth, 0))); p = DrawContour(CutEdge(QLineF(0, 0, d->paperWidth, 0)));
p.translate(d->paperWidth, d->paperHeight); p.translate(d->paperWidth/2, d->paperHeight/2);
paint.drawPath(p); paint.drawPath(p);
} }
else else
{ {
p = DrawContour(d->globalContour); p = DrawContour(d->globalContour);
p.translate(d->paperWidth, d->paperHeight); p.translate(d->paperWidth/2, d->paperHeight/2);
paint.drawPath(p); paint.drawPath(p);
} }
paint.setPen(QPen(Qt::darkGreen, 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); paint.setPen(QPen(Qt::darkGreen, 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p = DrawContour(detail.GetLayoutAllowencePoints()); p = DrawContour(detail.GetLayoutAllowencePoints());
p.translate(d->paperWidth, d->paperHeight); p.translate(d->paperWidth/2, d->paperHeight/2);
paint.drawPath(p); paint.drawPath(p);
#ifdef ARRANGED_DETAILS #ifdef ARRANGED_DETAILS
paint.setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); paint.setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p = DrawDetails(); p = DrawDetails();
p.translate(d->paperWidth, d->paperHeight); p.translate(d->paperWidth/2, d->paperHeight/2);
paint.drawPath(p); paint.drawPath(p);
#endif #endif