summaryrefslogtreecommitdiff
path: root/src/gui/tikzview.cpp
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2018-04-05 13:20:20 +0200
committerAleks Kissinger <aleks0@gmail.com>2018-04-05 13:20:20 +0200
commit1a71fd8efa0350d1e121f6792e8fad67e82b25c1 (patch)
tree0e706cf35256c5195974105218ad2b6ea49e1193 /src/gui/tikzview.cpp
parent8b8ea9395bdda4bb1404497ff654b82098084822 (diff)
fixed name conflict, now builds in MSVC
Diffstat (limited to 'src/gui/tikzview.cpp')
-rw-r--r--src/gui/tikzview.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/gui/tikzview.cpp b/src/gui/tikzview.cpp
index b8ae1c0..60dc2bc 100644
--- a/src/gui/tikzview.cpp
+++ b/src/gui/tikzview.cpp
@@ -7,7 +7,7 @@
TikzView::TikzView(QWidget *parent) : QGraphicsView(parent)
{
setRenderHint(QPainter::Antialiasing);
- setDragMode(QGraphicsView::RubberBandDrag);
+ //setDragMode(QGraphicsView::RubberBandDrag);
_scale = 1.0f;
}
@@ -24,10 +24,15 @@ void TikzView::zoomOut()
scale(0.625,0.625);
}
+void TikzView::setScene(QGraphicsScene *scene)
+{
+ QGraphicsView::setScene(scene);
+ centerOn(QPointF(0.0f,-230.0f));
+}
+
void TikzView::drawBackground(QPainter *painter, const QRectF &rect)
{
// draw the grid
- int step = GLOBAL_SCALE / 8;
QPen pen1;
pen1.setWidth(1);
@@ -43,38 +48,38 @@ void TikzView::drawBackground(QPainter *painter, const QRectF &rect)
painter->setPen(pen1);
if (_scale > 0.2f) {
- for (int x = -step; x > rect.left(); x -= step) {
- if (x % (step * 8) != 0) painter->drawLine(x, rect.top(), x, rect.bottom());
+ for (int x = -GRID_SEP; x > rect.left(); x -= GRID_SEP) {
+ if (x % (GRID_SEP * GRID_N) != 0) painter->drawLine(x, rect.top(), x, rect.bottom());
}
- for (int x = step; x < rect.right(); x += step) {
- if (x % (step * 8) != 0) painter->drawLine(x, rect.top(), x, rect.bottom());
+ for (int x = GRID_SEP; x < rect.right(); x += GRID_SEP) {
+ if (x % (GRID_SEP * GRID_N) != 0) painter->drawLine(x, rect.top(), x, rect.bottom());
}
- for (int y = -step; y > rect.top(); y -= step) {
- if (y % (step * 8) != 0) painter->drawLine(rect.left(), y, rect.right(), y);
+ for (int y = -GRID_SEP; y > rect.top(); y -= GRID_SEP) {
+ if (y % (GRID_SEP * GRID_N) != 0) painter->drawLine(rect.left(), y, rect.right(), y);
}
- for (int y = step; y < rect.bottom(); y += step) {
- if (y % (step * 8) != 0) painter->drawLine(rect.left(), y, rect.right(), y);
+ for (int y = GRID_SEP; y < rect.bottom(); y += GRID_SEP) {
+ if (y % (GRID_SEP * GRID_N) != 0) painter->drawLine(rect.left(), y, rect.right(), y);
}
}
painter->setPen(pen2);
- for (int x = -step*8; x > rect.left(); x -= step*8) {
+ for (int x = -GRID_SEP*GRID_N; x > rect.left(); x -= GRID_SEP*GRID_N) {
painter->drawLine(x, rect.top(), x, rect.bottom());
}
- for (int x = step*8; x < rect.right(); x += step*8) {
+ for (int x = GRID_SEP*GRID_N; x < rect.right(); x += GRID_SEP*GRID_N) {
painter->drawLine(x, rect.top(), x, rect.bottom());
}
- for (int y = -step*8; y > rect.top(); y -= step*8) {
+ for (int y = -GRID_SEP*GRID_N; y > rect.top(); y -= GRID_SEP*GRID_N) {
painter->drawLine(rect.left(), y, rect.right(), y);
}
- for (int y = step*8; y < rect.bottom(); y += step*8) {
+ for (int y = GRID_SEP*GRID_N; y < rect.bottom(); y += GRID_SEP*GRID_N) {
painter->drawLine(rect.left(), y, rect.right(), y);
}