[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [tikzkit] src/ui: cleanups
From: Dominik Haumann <dhaumann () kde ! org>
Date: 2014-04-30 22:31:57
Message-ID: E1Wfd2j-0007K6-D1 () scm ! kde ! org
[Download RAW message or body]
Git commit c459e215b4b5fa91c7bc2a1fe518bfcfb3023590 by Dominik Haumann.
Committed on 30/04/2014 at 22:31.
Pushed by dhaumann into branch 'master'.
cleanups
M +2 -0 src/ui/TikzView.cpp
M +16 -16 src/ui/utils/Grid.cpp
http://commits.kde.org/tikzkit/c459e215b4b5fa91c7bc2a1fe518bfcfb3023590
diff --git a/src/ui/TikzView.cpp b/src/ui/TikzView.cpp
index 227ee54..b92a446 100644
--- a/src/ui/TikzView.cpp
+++ b/src/ui/TikzView.cpp
@@ -74,6 +74,8 @@ TikzView::TikzView(TikzDocument * doc, QWidget * parent)
gridLayout->addWidget(viewport(), 1, 1);
setLayout(gridLayout);
+
+// setViewportUpdateMode(FullViewportUpdate);
}
TikzView::~TikzView()
diff --git a/src/ui/utils/Grid.cpp b/src/ui/utils/Grid.cpp
index 6365221..84e7f91 100644
--- a/src/ui/utils/Grid.cpp
+++ b/src/ui/utils/Grid.cpp
@@ -24,6 +24,9 @@
#include <QGraphicsView>
#include <QDebug>
+// TODO (later): make this unit configurable
+static const tikz::Unit s_unit = tikz::Centimeter;
+
namespace tikz {
namespace ui {
@@ -74,23 +77,20 @@ public:
rect = r;
zoom = z;
- // TODO (later): make this unit configurable
- const tikz::Unit unit = tikz::Centimeter;
-
// we want a line each 5 mm
- const int lpu = linesPerUnit(unit);
- qDebug() << "lines per unit" << lpu;
+ const int lpu = linesPerUnit(s_unit);
+// qDebug() << "lines per s_unit" << lpu;
majorLines.clear();
minorLines.clear();
- const Value one(1, unit);
+ const Value one(1, s_unit);
- tikz::Value left = \
tikz::Value(tikz::Value(rect.left()).convertTo(unit).value());
- left = tikz::Value(std::floor(left.value()), unit);
+ tikz::Value left = \
tikz::Value(tikz::Value(rect.left()).convertTo(s_unit).value()); + left = \
tikz::Value(std::floor(left.value()), s_unit);
- tikz::Value top = \
tikz::Value(tikz::Value(rect.top()).convertTo(unit).value());
- top = tikz::Value(std::ceil(top.value()), unit);
+ tikz::Value top = \
tikz::Value(tikz::Value(rect.top()).convertTo(s_unit).value()); + top = \
tikz::Value(std::ceil(top.value()), s_unit);
QVarLengthArray<QLineF, 100> lines;
int i = 0;
@@ -133,7 +133,8 @@ void Grid::draw(QPainter * p, const QRectF & rect)
d->updateCache(rect);
p->save();
-// QPen pen(QColor(243, 243, 243));
+ p->setRenderHints(QPainter::Antialiasing, false);
+
QPen pen(QColor(230, 230, 230));
pen.setWidth(0);
p->setPen(pen);
@@ -142,17 +143,16 @@ void Grid::draw(QPainter * p, const QRectF & rect)
pen.setDashPattern(QVector<qreal>() << 5 << 5);
p->setPen(pen);
p->drawLines(d->minorLines.data(), d->minorLines.size());
+
p->restore();
}
tikz::Value Grid::snapValue(const tikz::Value & value) const
{
- // TODO (later): make this unit configurable
- const tikz::Unit unit = tikz::Centimeter;
- const int lpu = d->linesPerUnit(unit);
- const Value one(1.0 / lpu, unit);
+ const int lpu = d->linesPerUnit(s_unit);
+ const Value one(1.0 / lpu, s_unit);
- const auto snappedValue = tikz::Value(qRound(value.convertTo(unit).value() / \
one.value()) * one.value(), unit).convertTo(value.unit()); + const auto \
snappedValue = tikz::Value(qRound(value.convertTo(s_unit).value() / one.value()) * \
one.value(), s_unit).convertTo(value.unit()); // qDebug() << value << "converts \
to:" << snappedValue; return snappedValue;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic