[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Wed Sep 10 17:57:52 CEST 2008
SVN commit 859548 by fenton:
Add Selective drawing of object details when printing.
M +10 -3 mainwindow.cpp
M +22 -20 plotrenderitem.cpp
M +6 -1 view.cpp
M +6 -0 view.h
M +32 -32 viewitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #859547:859548
@@ -280,13 +280,16 @@
pd.addEnabledOption(QPrintDialog::PrintPageRange);
if (pd.exec() == QDialog::Accepted) {
+
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+
QPainter painter(&printer);
- QList<QGraphicsView*> pages;
+ QList<View*> pages;
switch (printer.printRange()) {
case QPrinter::PageRange:
break;
case QPrinter::AllPages:
- foreach (QGraphicsView *view, _tabWidget->views()) {
+ foreach (View *view, _tabWidget->views()) {
pages.append(view);
}
break;
@@ -297,11 +300,15 @@
}
for (int i = 0; i < printer.numCopies(); ++i) {
- foreach (QGraphicsView *view, pages) {
+ foreach (View *view, pages) {
+ view->setPrinting(true);
view->render(&painter);
+ view->setPrinting(false);
printer.newPage();
}
}
+
+ QApplication::restoreOverrideCursor();
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #859547:859548
@@ -206,30 +206,32 @@
painter->restore();
- if (_selectionRect.isValid()) {
- painter->setPen(QPen(QBrush(Qt::black), 1.0, Qt::DotLine));
- painter->drawRect(_selectionRect.rect());
- }
+ if (!parentView()->isPrinting()) {
+ if (_selectionRect.isValid()) {
+ painter->setPen(QPen(QBrush(Qt::black), 1.0, Qt::DotLine));
+ painter->drawRect(_selectionRect.rect());
+ }
- painter->save();
- painter->setRenderHint(QPainter::Antialiasing, true);
- painter->fillPath(checkBox(), Qt::white);
- if (isHovering()) {
- QRectF check = checkBox().controlPointRect();
- check.setSize(QSizeF(check.width() / 1.8, check.height() / 1.8));
- check.moveCenter(checkBox().controlPointRect().center());
- QPainterPath p;
- p.addEllipse(check);
- painter->fillPath(p, Qt::black);
- }
- if (plotItem()->isTiedZoom()) {
painter->save();
- painter->setOpacity(0.5);
- painter->fillPath(checkBox(), Qt::black);
+ painter->setRenderHint(QPainter::Antialiasing, true);
+ painter->fillPath(checkBox(), Qt::white);
+ if (isHovering()) {
+ QRectF check = checkBox().controlPointRect();
+ check.setSize(QSizeF(check.width() / 1.8, check.height() / 1.8));
+ check.moveCenter(checkBox().controlPointRect().center());
+ QPainterPath p;
+ p.addEllipse(check);
+ painter->fillPath(p, Qt::black);
+ }
+ if (plotItem()->isTiedZoom()) {
+ painter->save();
+ painter->setOpacity(0.5);
+ painter->fillPath(checkBox(), Qt::black);
+ painter->restore();
+ }
+ painter->drawPath(checkBox());
painter->restore();
}
- painter->drawPath(checkBox());
- painter->restore();
#ifdef CURVE_DRAWING_TIME
int elapsed = time.elapsed();
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #859547:859548
@@ -37,7 +37,8 @@
_layoutBoxItem(0),
_gridSpacing(QSizeF(20,20)),
_snapToGridHorizontal(false),
- _snapToGridVertical(false) {
+ _snapToGridVertical(false),
+ _printing(false) {
_undoStack = new QUndoStack(this);
setScene(new Scene(this));
@@ -316,6 +317,10 @@
void View::drawBackground(QPainter *painter, const QRectF &rect) {
+ if (isPrinting()) {
+ return;
+ }
+
QGraphicsView::drawBackground(painter, rect);
if (!showGrid())
--- branches/work/kst/portto4/kst/src/libkstapp/view.h #859547:859548
@@ -87,6 +87,10 @@
QPointF snapPoint(const QPointF &point);
+ void setPrinting(bool printing) { _printing = printing; }
+ bool isPrinting() { return _printing; }
+
+
Q_SIGNALS:
void viewModeChanged(View::ViewMode oldMode);
void mouseModeChanged(View::MouseMode oldMode);
@@ -124,6 +128,8 @@
bool _showGrid;
bool _snapToGridHorizontal;
bool _snapToGridVertical;
+
+ bool _printing;
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #859547:859548
@@ -624,45 +624,45 @@
painter->setBrush(brush());
paint(painter); //this is the overload that subclasses should use...
- painter->save();
- painter->setPen(Qt::DotLine);
- painter->setBrush(Qt::NoBrush);
- if ((isSelected() || isHovering())
- && parentView()->mouseMode() != View::Create
- && parentView()->viewMode() != View::Data) {
- painter->drawPath(shape());
- if (_gripMode == Resize)
- painter->fillPath(grips(), Qt::blue);
- else if (_gripMode == Scale)
- painter->fillPath(grips(), Qt::black);
- else if (_gripMode == Rotate)
- painter->fillPath(grips(), Qt::red);
- else if (_gripMode == Move)
- painter->fillPath(grips(), Qt::transparent);
- }
+ if (!parentView()->isPrinting()) {
+ painter->save();
+ painter->setPen(Qt::DotLine);
+ painter->setBrush(Qt::NoBrush);
+ if ((isSelected() || isHovering())
+ && parentView()->mouseMode() != View::Create
+ && parentView()->viewMode() != View::Data) {
+ painter->drawPath(shape());
+ if (_gripMode == Resize)
+ painter->fillPath(grips(), Qt::blue);
+ else if (_gripMode == Scale)
+ painter->fillPath(grips(), Qt::black);
+ else if (_gripMode == Rotate)
+ painter->fillPath(grips(), Qt::red);
+ else if (_gripMode == Move)
+ painter->fillPath(grips(), Qt::transparent);
+ }
#ifdef DEBUG_GEOMETRY
-// painter->fillRect(selectBoundingRect(), Qt::blue);
- QColor semiRed(QColor(255, 0, 0, 50));
- painter->fillPath(shape(), semiRed);
+ // painter->fillRect(selectBoundingRect(), Qt::blue);
+ QColor semiRed(QColor(255, 0, 0, 50));
+ painter->fillPath(shape(), semiRed);
- QPen p = painter->pen();
+ QPen p = painter->pen();
- painter->setPen(Qt::white);
- painter->drawLine(_normalLine);
+ painter->setPen(Qt::white);
+ painter->drawLine(_normalLine);
- painter->setPen(Qt::red);
- painter->drawLine(_rotationLine);
- painter->setPen(p);
+ painter->setPen(Qt::red);
+ painter->drawLine(_rotationLine);
+ painter->setPen(p);
- painter->drawText(rect().topLeft(), "TL");
- painter->drawText(rect().topRight(), "TR");
- painter->drawText(rect().bottomLeft(), "BL");
- painter->drawText(rect().bottomRight(), "BR");
+ painter->drawText(rect().topLeft(), "TL");
+ painter->drawText(rect().topRight(), "TR");
+ painter->drawText(rect().bottomLeft(), "BL");
+ painter->drawText(rect().bottomRight(), "BR");
#endif
- painter->restore();
-
-// QGraphicsRectItem::paint(painter, option, widget);
+ painter->restore();
+ }
}
More information about the Kst
mailing list