yet clean qad/graphic
This commit is contained in:
@@ -5,11 +5,9 @@
|
|||||||
#include "ui_graphic_conf.h"
|
#include "ui_graphic_conf.h"
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
#include <QTapAndHoldGesture>
|
||||||
# include <QTapAndHoldGesture>
|
#include <QPanGesture>
|
||||||
# include <QPanGesture>
|
#include <QPinchGesture>
|
||||||
# include <QPinchGesture>
|
|
||||||
#endif
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
# include <QRandomGenerator>
|
# include <QRandomGenerator>
|
||||||
#endif
|
#endif
|
||||||
@@ -80,7 +78,6 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
|
|||||||
axis_type_x = Numeric;
|
axis_type_x = Numeric;
|
||||||
min_repaint_int = 25;
|
min_repaint_int = 25;
|
||||||
inc_x = 1.;
|
inc_x = 1.;
|
||||||
legy = 0;
|
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
gridx = gridy = 1.;
|
gridx = gridy = 1.;
|
||||||
history = 5.;
|
history = 5.;
|
||||||
@@ -359,7 +356,7 @@ void Graphic::canvasMouseMoveEvent(QMouseEvent * e) {
|
|||||||
case gaMove:
|
case gaMove:
|
||||||
dp = e->pos() - prevpos;
|
dp = e->pos() - prevpos;
|
||||||
dp.rx() *= selrect.width() / double(gridborder.x() + 5 - lastw);
|
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)
|
if (e->modifiers() == Qt::ControlModifier)
|
||||||
dp.setY(0.);
|
dp.setY(0.);
|
||||||
if (e->modifiers() == Qt::ShiftModifier)
|
if (e->modifiers() == Qt::ShiftModifier)
|
||||||
@@ -928,7 +925,7 @@ void Graphic::drawAction() {
|
|||||||
|
|
||||||
|
|
||||||
void Graphic::drawGrid() {
|
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;
|
double px, py, range, step, start;
|
||||||
int wid = cwid - gbx - 5, hei = chei - gby - 5, cx, cy, cnt;
|
int wid = cwid - gbx - 5, hei = chei - gby - 5, cx, cy, cnt;
|
||||||
QRect rect;
|
QRect rect;
|
||||||
@@ -1085,7 +1082,7 @@ void Graphic::drawGraphics() {
|
|||||||
if (isHover)
|
if (isHover)
|
||||||
ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
|
ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
|
||||||
QPointF srp = -selrect.topLeft();
|
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();
|
sclx = (wid - gridborder.x() - margins_.left() - margins_.width()) / selrect.width();
|
||||||
scly = (hei - gridborder.y() - margins_.top() - margins_.height()) / selrect.height();
|
scly = (hei - gridborder.y() - margins_.top() - margins_.height()) / selrect.height();
|
||||||
painter->setClipping(true);
|
painter->setClipping(true);
|
||||||
@@ -1250,7 +1247,7 @@ double Graphic::canvas2realX(double px) const {
|
|||||||
|
|
||||||
|
|
||||||
double Graphic::canvas2realY(double py) 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;
|
double cy = chei - py - gby, scly = selrect.height() / (double)hei;
|
||||||
return cy * scly + selrect.y();
|
return cy * scly + selrect.y();
|
||||||
}
|
}
|
||||||
@@ -1264,7 +1261,7 @@ double Graphic::real2canvasX(double px) const {
|
|||||||
|
|
||||||
|
|
||||||
double Graphic::real2canvasY(double py) 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;
|
double scly = selrect.height() / (double)hei;
|
||||||
return chei - gby - (py - selrect.y()) / scly;
|
return chei - gby - (py - selrect.y()) / scly;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,6 @@ public:
|
|||||||
QWidget * viewport() const {return canvas;}
|
QWidget * viewport() const {return canvas;}
|
||||||
QByteArray save();
|
QByteArray save();
|
||||||
void load(QByteArray ba);
|
void load(QByteArray ba);
|
||||||
void reset() {clear();}
|
|
||||||
|
|
||||||
GraphicType graphic(int arg) {if (arg < 0 || arg >= graphics.size()) return GraphicType(); return graphics[arg];}
|
GraphicType graphic(int arg) {if (arg < 0 || arg >= graphics.size()) return GraphicType(); return graphics[arg];}
|
||||||
const QVector<GraphicType> & allGraphics() const {return graphics;}
|
const QVector<GraphicType> & allGraphics() const {return graphics;}
|
||||||
@@ -386,7 +385,7 @@ protected:
|
|||||||
AxisType axis_type_x;
|
AxisType axis_type_x;
|
||||||
double gridx, gridy, history, visible_time, inc_x, grid_numbers_x, grid_numbers_y, LN10;
|
double gridx, gridy, history, visible_time, inc_x, grid_numbers_x, grid_numbers_y, LN10;
|
||||||
double eminx, eminy, emaxx, emaxy, pause_phase, gesture_angle;
|
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 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;
|
bool hasLblX, hasLblY, navigation, only_expand_y, only_expand_x, is_lines_update, leg_update, visible_update, fullscr, need_mouse_pan;
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ void MainWindow::saving(QPIConfig & conf) {
|
|||||||
vc = treeGraphics->topLevelItemCount();
|
vc = treeGraphics->topLevelItemCount();
|
||||||
for (int i = 0; i < vc; ++i) {
|
for (int i = 0; i < vc; ++i) {
|
||||||
QTreeWidgetItem * ti = treeGraphics->topLevelItem(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);
|
QByteArray ba; QDataStream s(&ba, QIODevice::WriteOnly);
|
||||||
s << graphic->allGraphics();
|
s << graphic->allGraphics();
|
||||||
|
|||||||
Reference in New Issue
Block a user