Commits
133 133 | asQwtPlot().print(painter, rect); |
134 134 | painter->drawRect(rect); |
135 135 | if (!op.null()) wasCanceled |= op->cancelRequested(); |
136 136 | } |
137 137 | return wasCanceled; |
138 138 | } |
139 139 | |
140 140 | bool QPCanvas::print( QPrinter& printer ){ |
141 141 | // Set orientation. |
142 142 | bool continuePrinting = true; |
143 + | |
144 + | printer.setPageOrientation(width() >= height() ? |
145 + | QPageLayout::Landscape : QPageLayout::Portrait); |
146 + | |
143 147 | printer.setOrientation(width() >= height() ? |
144 148 | QPrinter::Landscape : QPrinter::Portrait); |
149 + | |
145 150 | |
146 151 | QColor titleColor = asQwtPlot().title().color(); |
147 152 | |
148 153 | PlotOperationPtr op = operationExport(); |
149 154 | bool wasCanceled = false; |
150 155 | if(!op.null()){ |
151 156 | wasCanceled |= op->cancelRequested(); |
152 157 | } |
153 158 | if(wasCanceled){ |
154 159 | continuePrinting = false; |
183 188 | ) { |
184 189 | QImage image; |
185 190 | /*image = QPixmap::grabWidget(grabCanvas != NULL ? |
186 191 | &grabCanvas->asQwtPlot() : |
187 192 | grabPlotter->canvasWidget()).toImage();*/ |
188 193 | |
189 194 | image = m_canvas.grab().toImage(); |
190 195 | |
191 196 | image = QPixmap::grabWidget( &m_canvas ).toImage(); |
192 197 | |
193 - | |
198 + | |
194 199 | // Scale to set width and height, if applicable. |
195 200 | if (format.width > 0 && format.height > 0) { |
196 201 | // size is specified |
197 202 | image = image.scaled(format.width, format.height, |
198 203 | Qt::IgnoreAspectRatio, Qt::SmoothTransformation); |
199 204 | |
200 205 | } else if (format.width > 0) { |
201 206 | // width is specified |
202 207 | image = image.scaledToWidth(format.width, |
203 208 | Qt::SmoothTransformation); |
1476 1481 | |
1477 1482 | // somehow invalid |
1478 1483 | return coord; |
1479 1484 | } |
1480 1485 | |
1481 1486 | |
1482 1487 | |
1483 1488 | vector<double> QPCanvas::textWidthHeightDescent(const String& text, |
1484 1489 | PlotFontPtr font) const { |
1485 1490 | vector<double> v(3, 0); |
1486 - | |
1487 1491 | QFontMetrics mets(QPFont(*font).asQFont()); |
1492 + | |
1493 + | v[0] = mets.horizontalAdvance(text.c_str()); |
1494 + | |
1488 1495 | v[0] = mets.width(text.c_str()); |
1496 + | |
1489 1497 | v[1] = mets.ascent(); |
1490 1498 | v[2] = mets.descent(); |
1491 - | |
1499 + | |
1492 1500 | return v; |
1493 1501 | } |
1494 1502 | |
1495 1503 | |
1496 1504 | |
1497 1505 | PlotFactory* QPCanvas::implementationFactory() const { |
1498 1506 | return new QPFactory(); |
1499 1507 | } |
1500 1508 | |
1501 1509 | |
1715 1723 | else event->ignore(); |
1716 1724 | } |
1717 1725 | |
1718 1726 | bool QPCanvas::isDrawing() { |
1719 1727 | bool drawing = m_canvas.isDrawing(); |
1720 1728 | return drawing; |
1721 1729 | } |
1722 1730 | |
1723 1731 | |
1724 1732 | void QPCanvas::wheelEvent(QWheelEvent* event) { |
1733 + | |
1734 + | int delta = (event->angleDelta().manhattanLength() / 8) / 15; |
1735 + | |
1725 1736 | int delta = (event->delta() / 8) / 15; |
1737 + | |
1726 1738 | PlotCoordinate pcoord = globalPosToPixelCoord(event); |
1727 1739 | |
1728 1740 | if(notifyWheelHandlers(delta, pcoord)) event->accept(); |
1729 1741 | else event->ignore(); |
1730 1742 | } |
1731 1743 | |
1732 1744 | |
1733 1745 | void QPCanvas::resizeEvent(QResizeEvent* event) { |
1734 1746 | QSize o = event->oldSize(), n = event->size(); |
1735 1747 | if(notifyResizeHandlers(o.width(), o.height(), n.width(), n.height())) |