yet clean qad/graphic

This commit is contained in:
2020-06-18 20:21:37 +03:00
parent bd6e672568
commit d15b6ff855
3 changed files with 10 additions and 14 deletions

View File

@@ -5,11 +5,9 @@
#include "ui_graphic_conf.h"
#include <QMetaObject>
#include <QMessageBox>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
# include <QTapAndHoldGesture>
# include <QPanGesture>
# include <QPinchGesture>
#endif
#include <QTapAndHoldGesture>
#include <QPanGesture>
#include <QPinchGesture>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
# include <QRandomGenerator>
#endif
@@ -80,7 +78,6 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
axis_type_x = Numeric;
min_repaint_int = 25;
inc_x = 1.;
legy = 0;
buffer = 0;
gridx = gridy = 1.;
history = 5.;
@@ -359,7 +356,7 @@ void Graphic::canvasMouseMoveEvent(QMouseEvent * e) {
case gaMove:
dp = e->pos() - prevpos;
dp.rx() *= selrect.width() / double(gridborder.x() + 5 - lastw);
dp.ry() *= selrect.height() / double(lasth - legy - gridborder.y() - 5);
dp.ry() *= selrect.height() / double(lasth - gridborder.y() - 5);
if (e->modifiers() == Qt::ControlModifier)
dp.setY(0.);
if (e->modifiers() == Qt::ShiftModifier)
@@ -928,7 +925,7 @@ void Graphic::drawAction() {
void Graphic::drawGrid() {
int gbx = gridborder.x(), gby = gridborder.y(), cwid = canvas->width(), chei = canvas->height() - legy;
int gbx = gridborder.x(), gby = gridborder.y(), cwid = canvas->width(), chei = canvas->height();
double px, py, range, step, start;
int wid = cwid - gbx - 5, hei = chei - gby - 5, cx, cy, cnt;
QRect rect;
@@ -1085,7 +1082,7 @@ void Graphic::drawGraphics() {
if (isHover)
ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
QPointF srp = -selrect.topLeft();
double sclx, scly, wid = canvas->width(), hei = canvas->height() - legy;
double sclx, scly, wid = canvas->width(), hei = canvas->height();
sclx = (wid - gridborder.x() - margins_.left() - margins_.width()) / selrect.width();
scly = (hei - gridborder.y() - margins_.top() - margins_.height()) / selrect.height();
painter->setClipping(true);
@@ -1250,7 +1247,7 @@ double Graphic::canvas2realX(double px) const {
double Graphic::canvas2realY(double py) const {
int gby = gridborder.y() + margins_.top(), chei = lasth - legy, hei = chei - gby - margins_.height();
int gby = gridborder.y() + margins_.top(), chei = lasth, hei = chei - gby - margins_.height();
double cy = chei - py - gby, scly = selrect.height() / (double)hei;
return cy * scly + selrect.y();
}
@@ -1264,7 +1261,7 @@ double Graphic::real2canvasX(double px) const {
double Graphic::real2canvasY(double py) const {
int gby = gridborder.y() + margins_.top(), chei = lasth - legy, hei = chei - gby - margins_.height();
int gby = gridborder.y() + margins_.top(), chei = lasth, hei = chei - gby - margins_.height();
double scly = selrect.height() / (double)hei;
return chei - gby - (py - selrect.y()) / scly;
}