From kde-commits Wed Apr 30 22:16:28 2014 From: Dominik Haumann Date: Wed, 30 Apr 2014 22:16:28 +0000 To: kde-commits Subject: [tikzkit] src/ui: grid drawing is done in the View now Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=139889619900818 Git commit e6e6005198a06b7407c71c96c14643d6194266ae by Dominik Haumann. Committed on 30/04/2014 at 22:16. Pushed by dhaumann into branch 'master'. grid drawing is done in the View now M +0 -35 src/ui/TikzScene.cpp M +0 -4 src/ui/TikzScene.h http://commits.kde.org/tikzkit/e6e6005198a06b7407c71c96c14643d6194266ae diff --git a/src/ui/TikzScene.cpp b/src/ui/TikzScene.cpp index 91ba3a4..3c590e0 100644 --- a/src/ui/TikzScene.cpp +++ b/src/ui/TikzScene.cpp @@ -95,41 +95,6 @@ TikzEditMode TikzScene::editMode() const return d->editMode; } = -void TikzScene::drawBackground(QPainter *painter, const QRectF &rect) -{ - if (!rect.isValid()) { - qWarning() << "Scene bounding rect is invalid. Something is wrong!= "; - return; - } - - // painting is in unit 'pt' - - // desired unit - const tikz::Unit unit =3D tikz::Centimeter; - const Value one(1, unit); - - tikz::Value left =3D tikz::Value(tikz::Value(rect.left()).convertTo(un= it).value()); - left =3D tikz::Value(std::floor(left.value()), unit); - - tikz::Value top =3D tikz::Value(tikz::Value(rect.top()).convertTo(unit= ).value()); - top =3D tikz::Value(std::ceil(top.value()), unit); - - QVarLengthArray lines; - for (tikz::Value x =3D left; x.toPoint() < rect.right(); x +=3D one) { - lines.append(QLineF(x.toPoint(), rect.top(), x.toPoint(), rect.bot= tom())); - } - for (tikz::Value y =3D top; y.toPoint() < rect.bottom(); y +=3D one) { - lines.append(QLineF(rect.left(), y.toPoint(), rect.right(), y.toPo= int())); - } - - painter->save(); - QPen pen(QColor(243, 243, 243)); - pen.setWidth(0); - painter->setPen(pen); - painter->drawLines(lines.data(), lines.size()); - painter->restore(); -} - void TikzScene::mousePressEvent(QGraphicsSceneMouseEvent * event) { // first let QGraphicsScene do its work diff --git a/src/ui/TikzScene.h b/src/ui/TikzScene.h index 031b3ac..6ea44b0 100644 --- a/src/ui/TikzScene.h +++ b/src/ui/TikzScene.h @@ -73,10 +73,6 @@ class TIKZUI_EXPORT TikzScene : public QGraphicsScene void editModeChanged(TikzEditMode mode) const; = protected: - // Efficiently draws a grid in the background. - // For more information: http://www.qtcentre.org/threads/5609-Draw= ing-grids-efficiently-in-QGraphicsScene?p=3D28905#post28905 - void drawBackground(QPainter *painter, const QRectF &rect) overrid= e; - /** * Reimplemented to pass mouse press events to tool handler. */