+ p.translate(offset, offset);
+
+ /*
+ * Background
+ */
+ p.fillRect(rect().translated(-offset, -offset), palette().background());
+ if (!m_pixmap.isNull()) {
+ if (m_pixmapIsDirty || !m_pixmapCache) {
+ if (m_pixmapCache)
+ delete m_pixmapCache;
+ m_pixmapCache = new QPixmap(wWidth + 1, wHeight + 1);
+ QPainter cachePainter(m_pixmapCache);
+
+ cachePainter.scale(1.0*(wWidth+1) / m_pixmap.width(), 1.0*(wHeight+1) / m_pixmap.height());
+ cachePainter.drawPixmap(0, 0, m_pixmap);
+ m_pixmapIsDirty = false;
+ }
+ p.drawPixmap(0, 0, *m_pixmapCache);
+ }
+
+
+ p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
+
+ /*
+ * Borders
+ */
+ if (m_zoomLevel != 0) {
+ p.drawRect(0, 0, wWidth, wHeight);
+ }
+
+ /*
+ * Grid
+ */
+ if (m_gridLines != 0) {
+ double stepH = wWidth / (double)(m_gridLines + 1);
+ double stepV = wHeight / (double)(m_gridLines + 1);
+ for (int i = 1; i <= m_gridLines; ++i) {
+ p.drawLine(QLineF(i * stepH, 0, i * stepH, wHeight));
+ p.drawLine(QLineF(0, i * stepV, wWidth, i * stepV));
+ }
+ }
+
+ p.setRenderHint(QPainter::Antialiasing);
+