"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libs/ui/canvas/kis_grid_decoration.cpp" between
krita-5.1.3.tar.xz and krita-5.1.4.tar.xz

About: Krita is a painting program offering art tools for everyone (concept art, texture and matte painters, illustrations and comics).

kis_grid_decoration.cpp  (krita-5.1.3.tar.xz):kis_grid_decoration.cpp  (krita-5.1.4.tar.xz)
skipping to change at line 74 skipping to change at line 74
scaleCoeff *= 2; scaleCoeff *= 2;
} }
if (scaleCoeff > 32768) { if (scaleCoeff > 32768) {
qWarning() << "WARNING: Grid Scale Coeff is too high! That is surely a bug!"; qWarning() << "WARNING: Grid Scale Coeff is too high! That is surely a bug!";
return; return;
} }
} }
const QPen mainPen = m_d->config.penMain(); const QPen mainPen = m_d->config.penMain();
const QPen subdivisionPen = m_d->config.penSubdivision(); QPen subdivisionPen = m_d->config.penSubdivision();
gc.save(); gc.save();
gc.setTransform(transform); gc.setTransform(transform);
gc.setRenderHints(QPainter::Antialiasing, false); gc.setRenderHints(QPainter::Antialiasing, false);
gc.setRenderHints(QPainter::HighQualityAntialiasing, false); gc.setRenderHints(QPainter::HighQualityAntialiasing, false);
qreal x1, y1, x2, y2; QRectF updateRectInImagePixels =
QRectF imageRect =
converter->documentToImage(updateArea) & converter->documentToImage(updateArea) &
converter->imageRectInImagePixels(); converter->imageRectInImagePixels();
imageRect.getCoords(&x1, &y1, &x2, &y2);
// for angles. This will later be a combobox to select different types of op tions // for angles. This will later be a combobox to select different types of op tions
// also add options to hide specific lines (vertical, horizonta, angle 1, et c // also add options to hide specific lines (vertical, horizonta, angle 1, et c
KisGridConfig::GridType gridType = m_d->config.gridType(); KisGridConfig::GridType gridType = m_d->config.gridType();
if (gridType == KisGridConfig::GRID_RECTANGULAR) { if (gridType == KisGridConfig::GRID_RECTANGULAR) {
qreal x1, y1, x2, y2;
updateRectInImagePixels.getCoords(&x1, &y1, &x2, &y2);
// compensate the fact the getCoordt returns off-by-one pixel
// at the bottom right of the rect.
x2++;
y2++;
{ {
// vertical lines // vertical lines
const int offset = m_d->config.offset().x(); const int offset = m_d->config.offset().x();
const int step = scaleCoeff * m_d->config.spacing().x(); const int step = scaleCoeff * m_d->config.spacing().x();
const int lineIndexFirst = qCeil((x1 - offset) / step); const int lineIndexFirst = qCeil((x1 - offset) / step);
const int lineIndexLast = qFloor((x2 - offset) / step); const int lineIndexLast = qFloor((x2 - offset) / step);
subdivisionPen.setDashOffset(y1 * scale);
for (int i = lineIndexFirst; i <= lineIndexLast; i++) { for (int i = lineIndexFirst; i <= lineIndexLast; i++) {
int w = offset + i * step; int w = offset + i * step;
gc.setPen(i % subdivision == 0 ? mainPen : subdivisionPen); gc.setPen(i % subdivision == 0 ? mainPen : subdivisionPen);
gc.drawLine(QPointF(w, y1),QPointF(w, y2)); gc.drawLine(QPointF(w, y1),QPointF(w, y2));
} }
} }
{ {
// horizontal lines // horizontal lines
const int offset = m_d->config.offset().y(); const int offset = m_d->config.offset().y();
const int step = scaleCoeff * m_d->config.spacing().y(); const int step = scaleCoeff * m_d->config.spacing().y();
const int lineIndexFirst = qCeil((y1 - offset) / step); const int lineIndexFirst = qCeil((y1 - offset) / step);
const int lineIndexLast = qFloor((y2 - offset) / step); const int lineIndexLast = qFloor((y2 - offset) / step);
subdivisionPen.setDashOffset(x1 * scale);
for (int i = lineIndexFirst; i <= lineIndexLast; i++) { for (int i = lineIndexFirst; i <= lineIndexLast; i++) {
int w = offset + i * step; int w = offset + i * step;
gc.setPen(i % subdivision == 0 ? mainPen : subdivisionPen); gc.setPen(i % subdivision == 0 ? mainPen : subdivisionPen);
gc.drawLine(QPointF(x1, w),QPointF(x2, w)); gc.drawLine(QPointF(x1, w),QPointF(x2, w));
} }
} }
} }
if (gridType == KisGridConfig::GRID_ISOMETRIC) { if (gridType == KisGridConfig::GRID_ISOMETRIC) {
qreal x1, y1, x2, y2;
// get true coordinates, not just the updateArea // get true coordinates, not just the updateArea
QRectF trueImageRect = converter->imageRectInImagePixels(); QRectF trueImageRect = converter->imageRectInImagePixels();
trueImageRect.getCoords(&x1, &y1, &x2, &y2); trueImageRect.getCoords(&x1, &y1, &x2, &y2);
// compensate the fact the getCoordt returns off-by-one pixel
// at the bottom right of the rect.
x2++;
y2++;
const int offset = m_d->config.offset().x(); const int offset = m_d->config.offset().x();
const int offsetY = m_d->config.offset().y(); const int offsetY = m_d->config.offset().y();
const int cellSpacing = m_d->config.cellSpacing(); const int cellSpacing = m_d->config.cellSpacing();
gc.setClipping(true); gc.setClipping(true);
gc.setClipRect(imageRect, Qt::IntersectClip); gc.setClipRect(updateRectInImagePixels, Qt::IntersectClip);
// left angle // left angle
{ {
const qreal gridXAngle = m_d->config.angleLeft(); const qreal gridXAngle = m_d->config.angleLeft();
const qreal bottomRightOfImageY = y2; // this should be the height o f the image const qreal bottomRightOfImageY = y2; // this should be the height o f the image
qreal finalY = 0.0; qreal finalY = 0.0;
// figure out the spacing based off the angle. The spacing needs to be perpendicular to the angle, // figure out the spacing based off the angle. The spacing needs to be perpendicular to the angle,
// so we need to do a bit of trig to get the correct spacing. // so we need to do a bit of trig to get the correct spacing.
qreal correctedAngleSpacing = cellSpacing; qreal correctedAngleSpacing = cellSpacing;
 End of changes. 9 change blocks. 
5 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)