From d15b6ff8558eb2cbdbb3dbf4740962a3a8e6a7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Thu, 18 Jun 2020 20:21:37 +0300 Subject: [PATCH] yet clean qad/graphic --- qad/graphic/graphic.cpp | 19 ++++++++----------- qad/graphic/graphic.h | 3 +-- qad/graphic/qpicalculator/mainwindow.cpp | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/qad/graphic/graphic.cpp b/qad/graphic/graphic.cpp index f61a148..a77636d 100644 --- a/qad/graphic/graphic.cpp +++ b/qad/graphic/graphic.cpp @@ -5,11 +5,9 @@ #include "ui_graphic_conf.h" #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) -# include -# include -# include -#endif +#include +#include +#include #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) # include #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; } diff --git a/qad/graphic/graphic.h b/qad/graphic/graphic.h index bb9c8fd..c34bc15 100644 --- a/qad/graphic/graphic.h +++ b/qad/graphic/graphic.h @@ -205,7 +205,6 @@ public: QWidget * viewport() const {return canvas;} QByteArray save(); void load(QByteArray ba); - void reset() {clear();} GraphicType graphic(int arg) {if (arg < 0 || arg >= graphics.size()) return GraphicType(); return graphics[arg];} const QVector & allGraphics() const {return graphics;} @@ -386,7 +385,7 @@ protected: AxisType axis_type_x; double gridx, gridy, history, visible_time, inc_x, grid_numbers_x, grid_numbers_y, LN10; double eminx, eminy, emaxx, emaxy, pause_phase, gesture_angle; - int legy/*What is it?*/, lastw, lasth, min_repaint_int, timer_pause, thick; + int lastw, lasth, min_repaint_int, timer_pause, thick; bool aalias, aupdate, grid, guides, isFit, isOGL, isHover, bufferActive, cancel, pause_, gestures; bool hasLblX, hasLblY, navigation, only_expand_y, only_expand_x, is_lines_update, leg_update, visible_update, fullscr, need_mouse_pan; diff --git a/qad/graphic/qpicalculator/mainwindow.cpp b/qad/graphic/qpicalculator/mainwindow.cpp index db6dd80..4381f41 100644 --- a/qad/graphic/qpicalculator/mainwindow.cpp +++ b/qad/graphic/qpicalculator/mainwindow.cpp @@ -129,7 +129,7 @@ void MainWindow::saving(QPIConfig & conf) { vc = treeGraphics->topLevelItemCount(); for (int i = 0; i < vc; ++i) { QTreeWidgetItem * ti = treeGraphics->topLevelItem(i); - vars << QString::number(ti->backgroundColor(1).rgb()) << ti->text(2); + vars << QString::number(ti->background(1).color().rgb()) << ti->text(2); } QByteArray ba; QDataStream s(&ba, QIODevice::WriteOnly); s << graphic->allGraphics();