Mercurial > hg > svgui
comparison view/View.cpp @ 229:387f2f6fc333 sv1-1.0pre2
* Remove tip dialog for now. I don't like it enough
* Fixes to export image
author | Chris Cannam |
---|---|
date | Wed, 14 Mar 2007 14:39:39 +0000 |
parents | 6dab3ac2fe73 |
children | efadb9d2b2c6 |
comparison
equal
deleted
inserted
replaced
228:1c4c9e3e44e6 | 229:387f2f6fc333 |
---|---|
1610 | 1610 |
1611 paint.restore(); | 1611 paint.restore(); |
1612 } | 1612 } |
1613 | 1613 |
1614 bool | 1614 bool |
1615 View::render(QPainter &paint, QRect rect) | 1615 View::render(QPainter &paint, int xorigin, size_t f0, size_t f1) |
1616 { | 1616 { |
1617 size_t f0 = getModelsStartFrame(); | |
1618 size_t f1 = getModelsEndFrame(); | |
1619 | |
1620 size_t x0 = f0 / m_zoomLevel; | 1617 size_t x0 = f0 / m_zoomLevel; |
1621 size_t x1 = f1 / m_zoomLevel; | 1618 size_t x1 = f1 / m_zoomLevel; |
1622 | 1619 |
1623 size_t w = x1 - x0; | 1620 size_t w = x1 - x0; |
1624 | 1621 |
1678 m_centreFrame = origCentreFrame; | 1675 m_centreFrame = origCentreFrame; |
1679 update(); | 1676 update(); |
1680 return false; | 1677 return false; |
1681 } | 1678 } |
1682 | 1679 |
1683 m_centreFrame = (x + width()/2) * m_zoomLevel; | 1680 m_centreFrame = f0 + (x + width()/2) * m_zoomLevel; |
1684 | 1681 |
1685 QRect chunk(0, 0, width(), height()); | 1682 QRect chunk(0, 0, width(), height()); |
1686 | 1683 |
1687 if (hasLightBackground()) { | 1684 if (hasLightBackground()) { |
1688 paint.setPen(Qt::white); | 1685 paint.setPen(Qt::white); |
1690 } else { | 1687 } else { |
1691 paint.setPen(Qt::black); | 1688 paint.setPen(Qt::black); |
1692 paint.setBrush(Qt::black); | 1689 paint.setBrush(Qt::black); |
1693 } | 1690 } |
1694 | 1691 |
1695 paint.drawRect(QRect(rect.x() + x, rect.y(), width(), height())); | 1692 paint.drawRect(QRect(xorigin + x, 0, width(), height())); |
1696 | 1693 |
1697 paint.setPen(Qt::black); | 1694 paint.setPen(Qt::black); |
1698 paint.setBrush(Qt::NoBrush); | 1695 paint.setBrush(Qt::NoBrush); |
1699 | 1696 |
1700 for (LayerList::iterator i = m_layers.begin(); | 1697 for (LayerList::iterator i = m_layers.begin(); |
1701 i != m_layers.end(); ++i) { | 1698 i != m_layers.end(); ++i) { |
1702 | 1699 |
1703 paint.setRenderHint(QPainter::Antialiasing, false); | 1700 paint.setRenderHint(QPainter::Antialiasing, false); |
1704 | 1701 |
1705 paint.save(); | 1702 paint.save(); |
1706 paint.translate(rect.x() + x, rect.y()); | 1703 paint.translate(xorigin + x, 0); |
1707 | 1704 |
1708 // std::cerr << "Centre frame now: " << m_centreFrame << " drawing to " << chunk.x() << ", " << chunk.width() << std::endl; | 1705 std::cerr << "Centre frame now: " << m_centreFrame << " drawing to " << chunk.x() + x + xorigin << ", " << chunk.width() << std::endl; |
1709 | 1706 |
1710 (*i)->paint(this, paint, chunk); | 1707 (*i)->paint(this, paint, chunk); |
1711 | 1708 |
1712 paint.restore(); | 1709 paint.restore(); |
1713 } | 1710 } |
1722 View::toNewImage() | 1719 View::toNewImage() |
1723 { | 1720 { |
1724 size_t f0 = getModelsStartFrame(); | 1721 size_t f0 = getModelsStartFrame(); |
1725 size_t f1 = getModelsEndFrame(); | 1722 size_t f1 = getModelsEndFrame(); |
1726 | 1723 |
1724 return toNewImage(f0, f1); | |
1725 } | |
1726 | |
1727 QImage * | |
1728 View::toNewImage(size_t f0, size_t f1) | |
1729 { | |
1727 size_t x0 = f0 / getZoomLevel(); | 1730 size_t x0 = f0 / getZoomLevel(); |
1728 size_t x1 = f1 / getZoomLevel(); | 1731 size_t x1 = f1 / getZoomLevel(); |
1729 | 1732 |
1730 QImage *image = new QImage(x1 - x0, height(), QImage::Format_RGB32); | 1733 QImage *image = new QImage(x1 - x0, height(), QImage::Format_RGB32); |
1731 | 1734 |
1732 QPainter *paint = new QPainter(image); | 1735 QPainter *paint = new QPainter(image); |
1733 if (!render(*paint, image->rect())) { | 1736 if (!render(*paint, 0, f0, f1)) { |
1734 delete paint; | 1737 delete paint; |
1735 delete image; | 1738 delete image; |
1736 return 0; | 1739 return 0; |
1737 } else { | 1740 } else { |
1738 delete paint; | 1741 delete paint; |
1739 return image; | 1742 return image; |
1740 } | 1743 } |
1744 } | |
1745 | |
1746 QSize | |
1747 View::getImageSize() | |
1748 { | |
1749 size_t f0 = getModelsStartFrame(); | |
1750 size_t f1 = getModelsEndFrame(); | |
1751 | |
1752 return getImageSize(f0, f1); | |
1753 } | |
1754 | |
1755 QSize | |
1756 View::getImageSize(size_t f0, size_t f1) | |
1757 { | |
1758 size_t x0 = f0 / getZoomLevel(); | |
1759 size_t x1 = f1 / getZoomLevel(); | |
1760 | |
1761 return QSize(x1 - x0, height()); | |
1741 } | 1762 } |
1742 | 1763 |
1743 QString | 1764 QString |
1744 View::toXmlString(QString indent, QString extraAttributes) const | 1765 View::toXmlString(QString indent, QString extraAttributes) const |
1745 { | 1766 { |