git-svn-id: svn://db.shs.com.ru/libs@188 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
2
qad/graphic/CMakeLists.txt
Normal file
2
qad/graphic/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} qad_widgets qad_utils)
|
||||
qad_project(graphic "${LIBS}")
|
||||
1522
qad/graphic/graphic.cpp
Normal file
1522
qad/graphic/graphic.cpp
Normal file
@@ -0,0 +1,1522 @@
|
||||
#include "graphic.h"
|
||||
#include "ui_graphic.h"
|
||||
#include "ui_graphic_conf.h"
|
||||
|
||||
|
||||
__GraphicRegistrator__ __graphic_registrator__;
|
||||
|
||||
|
||||
ELineEdit::ELineEdit(QWidget * parent): CLineEdit(parent) {
|
||||
last_ret = complexd_0;
|
||||
is_auto = false;
|
||||
is_reset = true;
|
||||
connect(this, SIGNAL(editingFinished()), this, SLOT(calculate()));
|
||||
connect(this, SIGNAL(cleared()), this, SLOT(toDefaultClicked()));
|
||||
}
|
||||
|
||||
|
||||
void ELineEdit::wheelEvent(QWheelEvent * e) {
|
||||
double mul = 1.1;
|
||||
if (e->delta() < 0) mul = 0.9;
|
||||
CLineEdit::setText(QString::number(last_ret.real() * mul).toUpper());
|
||||
calculate();
|
||||
}
|
||||
|
||||
|
||||
void ELineEdit::calculate() {
|
||||
evaluator.check(text().replace(",", "."));
|
||||
if (!evaluator.isCorrect()) return;
|
||||
is_reset = false;
|
||||
last_ret = evaluator.evaluate();
|
||||
CLineEdit::setText(QString::number(last_ret.real()).toUpper());
|
||||
emit valueChanged(last_ret.real());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Graphic::Graphic(QWidget * parent): QFrame(parent), line_x_min(this), line_x_max(this), line_y_min(this), line_y_max(this) {
|
||||
QTranslator * trans = new QTranslator();
|
||||
trans->load(":/lang/qad_graphic_" + QLocale::system().name().left(2));
|
||||
if (trans->isEmpty())
|
||||
trans->load("lang/qad_graphic_" + QLocale::system().name().left(2));
|
||||
qApp->installTranslator(trans);
|
||||
leg_update = true;
|
||||
visible_update = fullscr = false;
|
||||
ui = new Ui::Graphic();
|
||||
ui->setupUi(this);
|
||||
/*line_x_min.resize(70, 22);
|
||||
line_x_max.resize(70, 22);
|
||||
line_y_min.resize(70, 22);
|
||||
line_y_max.resize(70, 22);*/
|
||||
line_x_min.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
line_x_max.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
((QBoxLayout * )ui->widgetLY->layout())->insertWidget(0, &line_y_min);
|
||||
((QBoxLayout * )ui->widgetLY->layout())->addWidget(&line_y_max);
|
||||
((QBoxLayout * )ui->widgetLX->layout())->insertWidget(0, &line_x_min);
|
||||
((QBoxLayout * )ui->widgetLX->layout())->addWidget(&line_x_max);
|
||||
tm.restart();
|
||||
grid_numbers_x = grid_numbers_y = 1;
|
||||
LN2 = qLn(2.);
|
||||
LN5 = qLn(5.);
|
||||
LN10 = qLn(10.);
|
||||
connect(&line_x_min, SIGNAL(valueChanged(double)), this, SLOT(lineXMinChanged(double)));
|
||||
connect(&line_x_max, SIGNAL(valueChanged(double)), this, SLOT(lineXMaxChanged(double)));
|
||||
connect(&line_y_min, SIGNAL(valueChanged(double)), this, SLOT(lineYMinChanged(double)));
|
||||
connect(&line_y_max, SIGNAL(valueChanged(double)), this, SLOT(lineYMaxChanged(double)));
|
||||
connect(ui->canvas_raster, SIGNAL(paintEvent(QPaintEvent * )), this, SLOT(canvasPaintEvent(QPaintEvent * )));
|
||||
connect(ui->canvas_raster, SIGNAL(mouseMoveEvent(QMouseEvent * )), this, SLOT(canvasMouseMoveEvent(QMouseEvent * )));
|
||||
connect(ui->canvas_raster, SIGNAL(mousePressEvent(QMouseEvent * )), this, SLOT(canvasMousePressEvent(QMouseEvent * )));
|
||||
connect(ui->canvas_raster, SIGNAL(mouseReleaseEvent(QMouseEvent * )), this, SLOT(canvasMouseReleaseEvent(QMouseEvent * )));
|
||||
connect(ui->canvas_raster, SIGNAL(mouseDoubleClickEvent(QMouseEvent*)), this, SLOT(canvasMouseDoubleClickEvent(QMouseEvent * )));
|
||||
connect(ui->canvas_raster, SIGNAL(wheelEvent(QWheelEvent * )), this, SLOT(canvasWheelEvent(QWheelEvent * )));
|
||||
connect(ui->canvas_raster, SIGNAL(leaveEvent(QEvent * )), this, SLOT(canvasLeaveEvent(QEvent * )));
|
||||
connect(ui->canvas_raster, SIGNAL(keyPressEvent(QKeyEvent * )), this, SLOT(canvasKeyPressEvent(QKeyEvent * )));
|
||||
connect(ui->canvas_gl, SIGNAL(paintEvent(QPaintEvent * )), this, SLOT(canvasPaintEvent(QPaintEvent * )));
|
||||
connect(ui->canvas_gl, SIGNAL(mouseMoveEvent(QMouseEvent * )), this, SLOT(canvasMouseMoveEvent(QMouseEvent * )));
|
||||
connect(ui->canvas_gl, SIGNAL(mousePressEvent(QMouseEvent * )), this, SLOT(canvasMousePressEvent(QMouseEvent * )));
|
||||
connect(ui->canvas_gl, SIGNAL(mouseReleaseEvent(QMouseEvent * )), this, SLOT(canvasMouseReleaseEvent(QMouseEvent * )));
|
||||
connect(ui->canvas_gl, SIGNAL(mouseDoubleClickEvent(QMouseEvent*)), this, SLOT(canvasMouseDoubleClickEvent(QMouseEvent * )));
|
||||
connect(ui->canvas_gl, SIGNAL(wheelEvent(QWheelEvent * )), this, SLOT(canvasWheelEvent(QWheelEvent * )));
|
||||
connect(ui->canvas_gl, SIGNAL(leaveEvent(QEvent * )), this, SLOT(canvasLeaveEvent(QEvent * )));
|
||||
connect(ui->canvas_gl, SIGNAL(keyPressEvent(QKeyEvent * )), this, SLOT(canvasKeyPressEvent(QKeyEvent * )));
|
||||
ui->canvas_raster->grabGesture(Qt::PinchGesture);
|
||||
ui->canvas_raster->grabGesture(Qt::PanGesture);
|
||||
ui->canvas_raster->installEventFilter(this);
|
||||
ui->canvas_gl->grabGesture(Qt::PinchGesture);
|
||||
ui->canvas_gl->grabGesture(Qt::PanGesture);
|
||||
ui->canvas_gl->installEventFilter(this);
|
||||
icon_exp_x = QIcon(":/icons/expand_x.png");
|
||||
icon_exp_y = QIcon(":/icons/expand_y.png");
|
||||
icon_exp_sx = QIcon(":/icons/expand_s_x.png");
|
||||
icon_exp_sy = QIcon(":/icons/expand_s_y.png");
|
||||
icon_pause_b = QImage(":/icons/pause-back.png");
|
||||
icon_pause_f = QImage(":/icons/pause-front.png");
|
||||
aupdate = grid = isFit = isEmpty = navigation = true;
|
||||
aalias = mupdate = bufferActive = isOGL = cancel = isPrinting = guides = hasLblX = hasLblY = isHover = false;
|
||||
pause_ = only_expand_x = only_expand_y = false;
|
||||
//qDebug() << -DBL_MAX/2. << DBL_MAX/2. << DBL_MIN;
|
||||
limit_.setCoords(-DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX);
|
||||
eminx = eminy = DBL_MAX;
|
||||
emaxx = emaxy = DBL_MIN;
|
||||
grad_x = grad_y = Auto;
|
||||
axis_type_x = Numeric;
|
||||
min_repaint_int = 25;
|
||||
inc_x = 1.;
|
||||
legy = 0;
|
||||
buffer = 0;
|
||||
gridx = gridy = 1.;
|
||||
history = 5.;
|
||||
min_int = 1;
|
||||
max_int = 200;
|
||||
mdm = 10.;
|
||||
visible_time = -1.;
|
||||
pause_phase = 0.;
|
||||
selrect.setRect(0., 0., 1., 1.);
|
||||
def_rect = selrect;
|
||||
margins_.setRect(4, 4, 4, 4);
|
||||
curaction = gaMove;
|
||||
selbrush.setStyle(Qt::SolidPattern);
|
||||
selbrush.setColor(QColor(60, 175, 255, 100));
|
||||
text_color = Qt::black;
|
||||
grid_pen = QPen(Qt::gray, 0., Qt::DotLine);
|
||||
//graph_pen = QPen(Qt::red);
|
||||
//graph_pen.setCosmetic(true);
|
||||
graphics.append(GraphicType());
|
||||
curGraphic = 0;
|
||||
selpen = QPen(Qt::black);
|
||||
selpen.setStyle(Qt::DashLine);
|
||||
back_color = Qt::white;
|
||||
buttons_ = AllButtons;
|
||||
setButtonsPosition(Graphic::Left);
|
||||
setOpenGL(false);
|
||||
setAntialiasing(false);
|
||||
setCaption("");
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
ui->layoutButtons->update();
|
||||
updateLegend();
|
||||
setRectToLines();
|
||||
conf = new GraphicConf(graphics, this);
|
||||
}
|
||||
|
||||
|
||||
Graphic::~Graphic() {
|
||||
delete conf;
|
||||
if (buffer != 0) delete buffer;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::changeEvent(QEvent * e) {
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
return;
|
||||
}
|
||||
QFrame::changeEvent(e);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::timerEvent(QTimerEvent * ) {
|
||||
pause_phase += 0.02;
|
||||
if (pause_phase > 1.)
|
||||
pause_phase -= 1.;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::eventFilter(QObject * o, QEvent * e) {
|
||||
//qDebug() << "event" << o << e;
|
||||
if (o == canvas) {
|
||||
switch (e->type()) {
|
||||
case QEvent::Gesture:
|
||||
foreach (QGesture * g, ((QGestureEvent*)e)->gestures())
|
||||
procGesture(g);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return QFrame::eventFilter(o, e);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::procGesture(QGesture * g) {
|
||||
if (!g) return;
|
||||
qDebug() << g;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::canvasPaintEvent(QPaintEvent * ) {
|
||||
if (is_lines_update) return;
|
||||
QMutexLocker ml(&mutex_);
|
||||
//static int pwid = 0, phei = 0;
|
||||
int wid = canvas->width(), hei = canvas->height();
|
||||
lastw = wid;
|
||||
lasth = hei;
|
||||
font_sz = fontMetrics().size(0, "0");
|
||||
font_sz.setHeight(font_sz.height() * 1.);
|
||||
font_sz.setWidth(font_sz.width() * 8);
|
||||
thick = qMax<int>(qRound(font_sz.height() / 15.), 1);
|
||||
if (buffer != 0) if (buffer->width() != wid || buffer->height() != hei) {delete buffer; buffer = 0;}
|
||||
if (buffer == 0) buffer = new QImage(wid, hei, QImage::Format_RGB32);
|
||||
if (bufferActive) {
|
||||
QPainter p(canvas);
|
||||
p.drawImage(0, 0, *buffer);
|
||||
painter = &p;
|
||||
if (curpos != startpos) drawAction();
|
||||
drawGuides();
|
||||
return;
|
||||
}
|
||||
//if (!aupdate && !mupdate && pwid == wid && phei == hei) return;
|
||||
/*if (pwid != wid || phei != hei) {
|
||||
line_x_min.move(0, hei - 35);
|
||||
line_x_max.move(0, 0);
|
||||
line_y_min.move(70, hei - line_x_min.height());
|
||||
line_y_max.move(wid - line_y_max.width(), hei - line_x_min.height());
|
||||
}
|
||||
line_x_min.setVisible(grid);
|
||||
line_x_max.setVisible(grid);
|
||||
line_y_min.setVisible(grid);
|
||||
line_y_max.setVisible(grid);*/
|
||||
//pwid = wid;
|
||||
//phei = hei;
|
||||
QPainter p;
|
||||
if (isOGL) {
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
p.begin(canvas);
|
||||
} else p.begin(buffer);
|
||||
p.fillRect(canvas->rect(), back_color);
|
||||
painter = &p;
|
||||
p.setFont(font());
|
||||
gridborder = QPoint(5, 5);
|
||||
if (grid) {
|
||||
gridborder += QPoint(font_sz.width(), font_sz.height());
|
||||
if (hasLblY) gridborder += QPoint(font_sz.height(), 0);
|
||||
if (hasLblX) gridborder += QPoint(0, font_sz.height());
|
||||
drawGrid();
|
||||
}
|
||||
p.setRenderHint(QPainter::Antialiasing, aalias);
|
||||
if (isOGL) {
|
||||
if (aalias) glEnable(GL_MULTISAMPLE);
|
||||
else glDisable(GL_MULTISAMPLE);
|
||||
}
|
||||
//p.setRenderHint(QPainter::HighQualityAntialiasing, aalias);
|
||||
if (!aalias) p.translate(-0.5, -0.5);
|
||||
drawGraphics();
|
||||
drawGuides();
|
||||
if (pause_) drawPause();
|
||||
emit graphicPaintEvent(&p);
|
||||
p.end();
|
||||
if (isOGL) return;
|
||||
p.begin(canvas);
|
||||
p.drawImage(0, 0, *buffer);
|
||||
p.end();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::canvasMouseMoveEvent(QMouseEvent * e) {
|
||||
isHover = true;
|
||||
curpos = e->pos();
|
||||
QPointF rp = canvas2real(QPointF(e->pos())), srp = canvas2real(startpos), crp = canvas2real(curpos), dp;
|
||||
QString cursorstr = tr("Cursor: ") + pointCoords(rp);
|
||||
emit graphicMouseMoveEvent(rp, e->buttons());
|
||||
if (e->buttons() == Qt::NoButton) {
|
||||
ui->status->setText(cursorstr);
|
||||
if (guides) update();
|
||||
return;
|
||||
}
|
||||
if (!navigation) return;
|
||||
if (curaction != gaMove && (e->buttons() & Qt::RightButton) == Qt::RightButton) return;
|
||||
switch (curaction) {
|
||||
case gaZoomInRect:
|
||||
ui->status->setText(tr("Selection") + ": " + pointCoords(srp) + " -> " +
|
||||
pointCoords(crp) + ", " + tr("Size") + ": " + pointCoords(absPoint(crp - srp)));
|
||||
repaintCanvas(true);
|
||||
break;
|
||||
case gaZoomRangeX:
|
||||
ui->status->setText(tr("Range") + ": " + QString::number(srp.x(), 'f', 3) +
|
||||
" -> " + QString::number(crp.x(), 'f', 3) + ", " + tr("Length") + ": " +
|
||||
QString::number(qAbs(crp.x() - srp.x()), 'f', 3));
|
||||
repaintCanvas(true);
|
||||
break;
|
||||
case gaZoomRangeY:
|
||||
ui->status->setText(tr("Range") + ": " + QString::number(srp.y(), 'f', 3) +
|
||||
" -> " + QString::number(crp.y(), 'f', 3) + ", " + tr("Length") + ": " +
|
||||
QString::number(qAbs(crp.y() - srp.y()), 'f', 3));
|
||||
repaintCanvas(true);
|
||||
break;
|
||||
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);
|
||||
selrect.translate(dp);
|
||||
isFit = false;
|
||||
emit visualRectChanged();
|
||||
update(true);
|
||||
setRectToLines();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
prevpos = e->pos();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::canvasMousePressEvent(QMouseEvent * e) {
|
||||
emit graphicMousePressEvent(canvas2real(QPointF(e->pos())), e->buttons());
|
||||
if (!navigation) return;
|
||||
ui->canvas_gl->setCursor(guides ? Qt::BlankCursor : Qt::ArrowCursor);
|
||||
ui->canvas_raster->setCursor(guides ? Qt::BlankCursor : Qt::ArrowCursor);
|
||||
prevpos = e->pos();
|
||||
startpos = prevpos;
|
||||
if (cancel) return;
|
||||
if (e->button() == Qt::MidButton) curaction = gaMove;
|
||||
if (e->button() == Qt::RightButton) {
|
||||
if (bufferActive) {
|
||||
curpos = startpos;
|
||||
repaintCanvas(true);
|
||||
swapToNormal();
|
||||
cancel = true;
|
||||
return;
|
||||
} else {
|
||||
prevaction = curaction;
|
||||
curaction = gaMove;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
if (e->modifiers() == Qt::ControlModifier) curaction = gaZoomRangeX;
|
||||
else if (e->modifiers() == Qt::ShiftModifier) curaction = gaZoomRangeY;
|
||||
else curaction = gaZoomInRect;
|
||||
switch (curaction) {
|
||||
case gaZoomInRect:
|
||||
case gaZoomRangeX:
|
||||
case gaZoomRangeY:
|
||||
swapToBuffer();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
setCurrentAction(curaction);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::canvasMouseReleaseEvent(QMouseEvent * e) {
|
||||
emit graphicMouseReleaseEvent(canvas2real(QPointF(e->pos())), e->buttons());
|
||||
if (!navigation) return;
|
||||
ui->canvas_gl->setCursor(guides ? Qt::BlankCursor : Qt::ArrowCursor);
|
||||
ui->canvas_raster->setCursor(guides ? Qt::BlankCursor : Qt::ArrowCursor);
|
||||
QPointF tlp, brp;
|
||||
QRect sr;
|
||||
sr = QRect(startpos, curpos).normalized();
|
||||
if (cancel) {
|
||||
if (e->buttons() == Qt::NoButton) cancel = false;
|
||||
return;
|
||||
}
|
||||
if (e->button() == Qt::RightButton && curaction == gaMove) {
|
||||
curaction = prevaction;
|
||||
return;
|
||||
}
|
||||
if (e->button() == Qt::LeftButton && (e->buttons() & Qt::RightButton) != Qt::RightButton) {
|
||||
if (curpos != startpos) {
|
||||
tlp = canvas2real(sr.topLeft());
|
||||
brp = canvas2real(sr.bottomRight());
|
||||
isFit = false;
|
||||
switch (curaction) {
|
||||
case gaZoomInRect:
|
||||
if (sr.width() <= 1 || sr.height() <= 1) break;
|
||||
selrect.setCoords(tlp.x(), brp.y(), brp.x(), tlp.y());
|
||||
setRectToLines();
|
||||
break;
|
||||
case gaZoomRangeX:
|
||||
if (sr.width() <= 1) break;
|
||||
findGraphicsRect(tlp.x(), brp.x());
|
||||
break;
|
||||
case gaZoomRangeY:
|
||||
if (sr.height() <= 1) break;
|
||||
findGraphicsRect(0., 0., brp.y(), tlp.y());
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
swapToNormal();
|
||||
update(true);
|
||||
}
|
||||
QPointF rp = canvas2real(QPointF(e->pos()));
|
||||
ui->status->setText(tr("Cursor") + ": " + pointCoords(rp));
|
||||
emit visualRectChanged();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::canvasMouseDoubleClickEvent(QMouseEvent * ) {
|
||||
autofit();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::canvasWheelEvent(QWheelEvent * e) {
|
||||
//if (curaction != gaMove) return;
|
||||
emit graphicWheelEvent(canvas2real(QPointF(e->pos())), e->delta());
|
||||
if (!navigation) return;
|
||||
double scl, wid = canvas->width() - gridborder.x() - margins_.width() - margins_.left(), hei = canvas->height() - gridborder.y() - margins_.height() - margins_.top();
|
||||
double px = e->pos().x() - gridborder.x() - margins_.left(), py = hei - e->pos().y() + margins_.height();
|
||||
px = px / wid * selrect.width() + selrect.x();
|
||||
py = py / hei * selrect.height() + selrect.y();
|
||||
if (e->delta() > 0) scl = 1. / 1.2;
|
||||
else scl = 1.2;
|
||||
if (e->modifiers() == Qt::NoModifier)
|
||||
selrect.setRect(px - (px - selrect.x()) * scl, py - (py - selrect.y()) * scl, selrect.width() * scl, selrect.height() * scl);
|
||||
else {
|
||||
if (e->modifiers() == Qt::ControlModifier)
|
||||
selrect.setRect(px - (px - selrect.x()) * scl, selrect.y(), selrect.width() * scl, selrect.height());
|
||||
if (e->modifiers() == Qt::ShiftModifier)
|
||||
selrect.setRect(selrect.x(), py - (py - selrect.y()) * scl, selrect.width(), selrect.height() * scl);
|
||||
}
|
||||
isFit = false;
|
||||
update(true);
|
||||
setRectToLines();
|
||||
emit visualRectChanged();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::zoom(float factor) {
|
||||
double wid = canvas->width() - gridborder.x() - margins_.width() - margins_.left(), hei = canvas->height() - gridborder.y() - margins_.height() - margins_.top();
|
||||
double px = wid / 2, py = hei / 2;
|
||||
px = px / wid * selrect.width() + selrect.x();
|
||||
py = py / hei * selrect.height() + selrect.y();
|
||||
selrect.setRect(px - (px - selrect.x()) * factor, py - (py - selrect.y()) * factor, selrect.width() * factor, selrect.height() * factor);
|
||||
isFit = false;
|
||||
update(true);
|
||||
setRectToLines();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::fullscreen() {
|
||||
if (fullscr) leaveFullscreen();
|
||||
else enterFullscreen();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::canvasLeaveEvent(QEvent * ) {
|
||||
isHover = false;
|
||||
if (guides) update(true);
|
||||
ui->status->setText(tr("Cursor") + ": ( ; )");
|
||||
leaveFullscreen();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::canvasKeyPressEvent(QKeyEvent * e) {
|
||||
switch (e->key()) {
|
||||
case Qt::Key_Escape: leaveFullscreen();
|
||||
default: break;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
void Graphic::clear() {
|
||||
//cout << "clear" << endl;
|
||||
for (int i = 0; i < graphics.size(); ++i) {
|
||||
graphics[i].polyline.clear();
|
||||
graphics[i].polyline_pause.clear();
|
||||
graphics[i].max_x = 0.;
|
||||
}
|
||||
on_buttonAutofit_clicked();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setAntialiasing(bool enabled) {
|
||||
if (aalias == enabled) return;
|
||||
aalias = enabled;
|
||||
/*QGLFormat f = ui->canvas_gl->format();
|
||||
f.setSampleBuffers(enabled);
|
||||
ui->canvas_gl->setFormat(f);*/
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setPaused(bool yes) {
|
||||
pause_ = yes;
|
||||
ui->checkPause->blockSignals(true);
|
||||
ui->checkPause->setChecked(yes);
|
||||
ui->checkPause->blockSignals(false);
|
||||
if (!pause_) {
|
||||
killTimer(timer_pause);
|
||||
timer_pause = 0;
|
||||
update(true);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < graphics.size(); ++i) {
|
||||
graphics[i].polyline_pause = graphics[i].polyline;
|
||||
graphics[i].polyline_pause.detach();
|
||||
graphics[i].max_x_pause = graphics[i].max_x;
|
||||
}
|
||||
timer_pause = startTimer(40);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setHistorySize(double val) {
|
||||
history = val;
|
||||
double x;
|
||||
for (int i = 0; i < graphics.size(); ++i) {
|
||||
QPolygonF & pol(graphics[i].polyline);
|
||||
if (pol.isEmpty() || history <= 0.) continue;
|
||||
x = pol.back().x() - history;
|
||||
for (int j = pol.size() - 2; j >= 0 ; --j)
|
||||
if (pol[j].x() < x) {
|
||||
//qDebug() << pol.size() << j;
|
||||
pol.erase(pol.begin(), pol.begin() + j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setOnlyExpandY(bool yes) {
|
||||
only_expand_y = yes;
|
||||
ui->checkExpandY->blockSignals(true);
|
||||
ui->checkExpandY->setCheckable(yes);
|
||||
ui->checkExpandY->blockSignals(false);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setOnlyExpandX(bool yes) {
|
||||
only_expand_x = yes;
|
||||
ui->checkExpandX->blockSignals(true);
|
||||
ui->checkExpandX->setCheckable(yes);
|
||||
ui->checkExpandX->blockSignals(false);
|
||||
}
|
||||
|
||||
|
||||
Graphic::GraphicsData Graphic::graphicsData() const {
|
||||
GraphicsData ret;
|
||||
ret.resize(graphics.size());
|
||||
for (int i = 0; i < graphics.size(); ++i)
|
||||
ret[i] = graphics[i].polyline;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setGraphicsData(const Graphic::GraphicsData & gd) {
|
||||
setGraphicsCount(gd.size());
|
||||
for (int i = 0; i < gd.size(); ++i)
|
||||
setGraphicData(gd[i], i, false);
|
||||
updateGraphics();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setButtons(Graphic::Buttons b) {
|
||||
buttons_ = b;
|
||||
ui->buttonAutofit->setVisible(b.testFlag(Autofit));
|
||||
ui->checkGrid->setVisible(b.testFlag(Grid));
|
||||
ui->checkGuides->setVisible(b.testFlag(CursorAxis));
|
||||
ui->checkExpandY->setVisible(b.testFlag(OnlyExpandY));
|
||||
ui->checkExpandX->setVisible(b.testFlag(OnlyExpandX));
|
||||
ui->buttonFullscreen->setVisible(b.testFlag(Fullscreen));
|
||||
ui->checkBorderInputs->setVisible(b.testFlag(BorderInputs));
|
||||
ui->checkLegend->setVisible(b.testFlag(Legend));
|
||||
ui->buttonClear->setVisible(b.testFlag(Clear));
|
||||
ui->buttonConfigure->setVisible(b.testFlag(Configure));
|
||||
ui->buttonSave->setVisible(b.testFlag(Save));
|
||||
ui->buttonClose->setVisible(b.testFlag(Close));
|
||||
ui->checkPause->setVisible(b.testFlag(Pause));
|
||||
if (ui->buttonAutofit->isVisible() || ui->checkGrid->isVisible() || ui->checkGuides->isVisible() ||
|
||||
ui->buttonConfigure->isVisible() || ui->buttonSave->isVisible() || ui->checkPause->isVisible())
|
||||
ui->verticalSpacer->changeSize(0, 30, QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
else
|
||||
ui->verticalSpacer->changeSize(0, 0, QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
ui->layoutButtons->update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setButtonsPosition(Graphic::Alignment a) {
|
||||
align = a;
|
||||
ui->widgetLeft->hide();
|
||||
ui->widgetRight->hide();
|
||||
switch (a) {
|
||||
case Graphic::Left:
|
||||
ui->widgetLeft->setLayout(ui->layoutButtons);
|
||||
ui->widgetLeft->show();
|
||||
break;
|
||||
case Graphic::Right:
|
||||
ui->widgetRight->setLayout(ui->layoutButtons);
|
||||
ui->widgetRight->show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Graphic::addPoint(const QPointF & p, int graphic, bool update_) {
|
||||
if (graphic >= graphics.size() || graphic < 0) return;
|
||||
if (graphics.at(graphic).polyline.size() == 0) graphics[graphic].max_x = p.x();
|
||||
graphics[graphic].polyline << p;
|
||||
if (graphics.at(graphic).max_x < p.x()) graphics[graphic].max_x = p.x();
|
||||
tick(graphic, true, update_);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic, bool update_) {
|
||||
if (graphic >= graphics.size() || graphic < 0) return;
|
||||
graphics[graphic].polyline.clear();
|
||||
graphics[graphic].polyline = g;
|
||||
if (graphics.at(graphic).polyline.size() == 0) {
|
||||
graphics[graphic].max_x = 0.;
|
||||
tick(graphic, false, update_);
|
||||
return;
|
||||
}
|
||||
graphics[graphic].max_x = graphics.at(graphic).polyline[0].x();
|
||||
for (int i = 1; i < graphics.at(graphic).polyline.size(); ++i)
|
||||
if (graphics.at(graphic).max_x < graphics.at(graphic).polyline[i].x())
|
||||
graphics[graphic].max_x = graphics.at(graphic).polyline[i].x();
|
||||
tick(graphic, false, update_);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setGraphicProperties(int graphic, const QString & name, const QColor& color, Qt::PenStyle style, double width, bool visible) {
|
||||
if (graphic < 0 || graphic >= graphics.size()) return;
|
||||
graphics[graphic].name = name;
|
||||
graphics[graphic].pen.setColor(color);
|
||||
graphics[graphic].pen.setStyle(style);
|
||||
graphics[graphic].pen.setWidth(width);
|
||||
graphics[graphic].visible = visible;
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::addGraphic(const QString & name, const QColor & color, Qt::PenStyle style, double width, bool visible) {
|
||||
graphics << GraphicType(name, color, style, width, visible);
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setVisualRect(const QRectF & rect) {
|
||||
selrect = rect;
|
||||
isFit = false;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setDefaultRect(const QRectF & rect) {
|
||||
def_rect = rect;
|
||||
if (isFit) autofit();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::saveImage() {
|
||||
QString str = QFileDialog::getSaveFileName(this, tr("Save Image"), ppath, "PNG(*.png);;JPEG(*.jpg *.jpeg);;BMP(*.bmp);;TIFF(*.tiff *.tif);;PPM(*.ppm)");
|
||||
if (str == "") return;
|
||||
ppath = str;
|
||||
QPixmap im(canvas->size());
|
||||
mupdate = true;
|
||||
canvas->render(&im);
|
||||
mupdate = false;
|
||||
im.save(ppath);
|
||||
update(true);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setOpenGL(bool on) {
|
||||
isOGL = on;
|
||||
if (on) {
|
||||
ui->canvas_raster->hide();
|
||||
ui->canvas_gl->show();
|
||||
canvas = ui->canvas_gl;
|
||||
} else {
|
||||
ui->canvas_gl->hide();
|
||||
ui->canvas_raster->show();
|
||||
canvas = ui->canvas_raster;
|
||||
}
|
||||
/*line_x_min.setParent(canvas);
|
||||
line_x_max.setParent(canvas);
|
||||
line_y_min.setParent(canvas);
|
||||
line_y_max.setParent(canvas);
|
||||
line_x_min.show();
|
||||
line_x_max.show();
|
||||
line_y_min.show();
|
||||
line_y_max.show();*/
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::update(bool force) {
|
||||
mupdate = true;
|
||||
repaintCanvas(force);
|
||||
mupdate = false;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setGraphicsCount(int arg, bool update) {
|
||||
if (arg < 0) return;
|
||||
while (graphics.size() < arg)
|
||||
graphics.append(GraphicType(tr("y(x)"), QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - qrand() % 115)));
|
||||
while (graphics.size() > arg) {
|
||||
delete graphics.back().pb;
|
||||
graphics.pop_back();
|
||||
}
|
||||
if (update) updateLegend();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setHistogramData(const QVector<float> & g, int graphic) {
|
||||
graphics[graphic].polyline.clear();
|
||||
if (g.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QVector<float> data = g;
|
||||
QVector<int> hist;
|
||||
int ic = max_int, ci;
|
||||
double md, cd, min, max, range, cx;
|
||||
qSort(data);
|
||||
md = DBL_MAX;
|
||||
min = max = data[0];
|
||||
for (int i = 1; i < data.size(); ++i) {
|
||||
if (min > data[i]) min = data[i];
|
||||
if (max < data[i]) max = data[i];
|
||||
cd = qAbs<float>(data[i] - data[i - 1]);
|
||||
if (md > cd && cd != 0.) md = cd;
|
||||
}
|
||||
range = max - min;
|
||||
md = mdm;
|
||||
//qDebug() << md << range << ic;
|
||||
if (md != 0.)
|
||||
ic = qRound(qMax<double>(qMin<double>(double(ic), range / md), double(min_int)));
|
||||
md = range / ic;
|
||||
hist.resize(ic);
|
||||
foreach (const float & i, data) {
|
||||
ci = qRound((i - min) / range * double(ic - 1));
|
||||
//if (ci < 0) ci = 0;
|
||||
//if (ci >= ic) ci = ic - 1;
|
||||
hist[ci]++;
|
||||
}
|
||||
QPolygonF & cpol(graphics[graphic].polyline);
|
||||
if (hist.size() == 1 || range == 0.) {
|
||||
cpol << QPointF(min - 0.5, 0.) << QPointF(min - 0.25, 0.);
|
||||
cpol << QPointF(min - 0.25, hist[0]) << QPointF(min + 0.25, hist[0]);
|
||||
cpol << QPointF(min + 0.25, 0.) << QPointF(min + 0.5, 0.);
|
||||
} else {
|
||||
cpol << QPointF(min, 0.);
|
||||
for (int i = 0; i < hist.size(); ++i) {
|
||||
cx = i * range / ic + min;
|
||||
cpol << QPointF(cx, hist[i]) << QPointF(cx + md, hist[i]);
|
||||
}
|
||||
cpol << QPointF(range + min, 0.);
|
||||
}
|
||||
updateGraphics();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::findGraphicsRect(double start_x, double end_x, double start_y, double end_y) {
|
||||
double cx, cy, maxX, minX, maxY, minY, vx = DBL_MIN;
|
||||
bool isRangeX = (start_x != end_x), isRangeY = (start_y != end_y);
|
||||
bool isEmpty = true, anyVisible = false, isTimeLimit = (visible_time > 0.) && !(isRangeX || isRangeY);
|
||||
foreach (const GraphicType & t, graphics) {
|
||||
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
|
||||
if (!pol.isEmpty()) {
|
||||
isEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isEmpty) {
|
||||
grect = def_rect;
|
||||
setRectToLines();
|
||||
return;
|
||||
}
|
||||
minY = minX = DBL_MAX;
|
||||
maxY = maxX = -DBL_MAX;
|
||||
foreach (const GraphicType & t, graphics) {
|
||||
if (!t.visible) continue;
|
||||
if (vx < (pause_ ? t.max_x_pause : t.max_x)) vx = (pause_ ? t.max_x_pause : t.max_x);
|
||||
}
|
||||
vx -= visible_time;
|
||||
foreach (const GraphicType & t, graphics) {
|
||||
if (!t.visible) continue;
|
||||
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
|
||||
for (int i = 0; i < pol.size(); i++) {
|
||||
cx = pol[i].x();
|
||||
cy = pol[i].y();
|
||||
if ((start_x > cx || end_x < cx) && isRangeX) continue;
|
||||
if ((start_y > cy || end_y < cy) && isRangeY) continue;
|
||||
if ((cx < vx) && isTimeLimit) continue;
|
||||
if (maxY < cy) maxY = cy;
|
||||
if (minY > cy) minY = cy;
|
||||
if (maxX < cx) maxX = cx;
|
||||
if (minX > cx) minX = cx;
|
||||
}
|
||||
if (!pol.isEmpty()) anyVisible = true;
|
||||
}
|
||||
if (!anyVisible) {
|
||||
grect.setRect(0., 0., 1., 1.);
|
||||
setRectToLines();
|
||||
return;
|
||||
}
|
||||
if (maxX > limit_.right()) maxX = limit_.right();
|
||||
if (minX > limit_.right()) minX = limit_.right();
|
||||
if (minX < limit_.left()) minX = limit_.left();
|
||||
if (maxX < limit_.left()) maxX = limit_.left();
|
||||
if (maxY > limit_.bottom()) maxY = limit_.bottom();
|
||||
if (minY > limit_.bottom()) minY = limit_.bottom();
|
||||
if (minY < limit_.top()) minY = limit_.top();
|
||||
if (maxY < limit_.top()) maxY = limit_.top();
|
||||
if (minX > maxX) qSwap<double>(minX, maxX);
|
||||
if (minY > maxY) qSwap<double>(minY, maxY);
|
||||
if (qAbs<double>(minX - maxX) < 1E-60) {minX -= 1E-20; maxX += 1E-20;}
|
||||
if (qAbs<double>(minY - maxY) < 1E-60) {minY -= 1E-20; maxY += 1E-20;}
|
||||
if (only_expand_x) {
|
||||
if (minX > eminx) minX = eminx;
|
||||
if (maxX < emaxx) maxX = emaxx;
|
||||
}
|
||||
if (only_expand_y) {
|
||||
if (minY > eminy) minY = eminy;
|
||||
if (maxY < emaxy) maxY = emaxy;
|
||||
}
|
||||
eminx = minX; emaxx = maxX;
|
||||
eminy = minY; emaxy = maxY;
|
||||
if (isRangeX) selrect.setRect(start_x, minY, end_x - start_x, maxY - minY);
|
||||
else if (isRangeY) selrect.setRect(minX, start_y, maxX - minX, end_y - start_y);
|
||||
else grect.setRect(minX, minY, maxX - minX, maxY - minY);
|
||||
grect = grect.normalized();
|
||||
if (isFit)/* || isRangeX || isRangeY)*/ selrect = grect;
|
||||
setRectToLines();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::drawAction() {
|
||||
//qDebug() << "draw action";
|
||||
int wid = canvas->width(), hei = canvas->height() - gridborder.y(), sx = startpos.x(), sy = startpos.y(), cx = curpos.x(), cy = curpos.y();
|
||||
painter->setPen(selpen);
|
||||
painter->setBrush(selbrush);
|
||||
switch (curaction) {
|
||||
case gaZoomInRect:
|
||||
painter->drawRect(QRect(startpos, curpos));
|
||||
break;
|
||||
case gaZoomRangeX:
|
||||
painter->drawLine(sx, hei, sx, 0);
|
||||
painter->drawLine(cx, hei, cx, 0);
|
||||
painter->fillRect(sx, 0, cx - sx, hei, selbrush);
|
||||
break;
|
||||
case gaZoomRangeY:
|
||||
painter->drawLine(gridborder.x(), sy, wid, sy);
|
||||
painter->drawLine(gridborder.x(), cy, wid, cy);
|
||||
painter->fillRect(gridborder.x(), sy, wid - gridborder.x(), cy - sy, selbrush);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Graphic::drawGrid() {
|
||||
int gbx = gridborder.x(), gby = gridborder.y(), cwid = painter->viewport().width(), chei = painter->viewport().height() - legy;
|
||||
double px, py, range, step, start;
|
||||
int wid = cwid - gbx - 5, hei = chei - gby - 5, cx, cy, cnt;
|
||||
QRect rect;
|
||||
QPair<QString, QString> str;
|
||||
|
||||
range = selrect.bottom() - selrect.top();
|
||||
if (grad_y == Graphic::Auto) step = splitRange(range, hei / gridy / font_sz.height() / 1.4);
|
||||
else step = gridy;//range / hei * gridy;
|
||||
start = roundTo(canvas2realY(-hei), step) - step;
|
||||
py = start + step;
|
||||
cy = 0;
|
||||
cx = gbx - 5;
|
||||
grid_pen.setWidth(qMax<int>(qRound(thick / 1.4), 1));
|
||||
QFont sf = font();
|
||||
QFont nf = sf;
|
||||
sf.setPointSizeF(qMax<qreal>(sf.pointSizeF() / 1.6, 7.));
|
||||
QFontMetrics fm(nf), sfm(sf);
|
||||
if (step > 0.) {
|
||||
cnt = 1000;
|
||||
while (cnt-- > 0) {
|
||||
py -= step;
|
||||
if (fabs(py) < step * .5) py = 0.;
|
||||
cy = real2canvasY(py);
|
||||
if (cy < 0) continue;
|
||||
if (cy > hei + 5) break;
|
||||
painter->setPen(grid_pen);
|
||||
painter->drawLine(gbx, cy, cwid, cy);
|
||||
str = gridMark(py * grid_numbers_y);
|
||||
painter->setPen(text_color);
|
||||
cy += font_sz.height() / 4.;
|
||||
int dx = font_sz.height() / 8.;
|
||||
if (!str.second.isEmpty()) {
|
||||
rect = sfm.boundingRect(str.second);
|
||||
painter->setFont(sf);
|
||||
painter->drawText(cx - rect.width() - dx, cy - font_sz.height() / 2.5, str.second);
|
||||
dx += rect.width() + font_sz.height() / 6.;
|
||||
}
|
||||
rect = fm.boundingRect(str.first);
|
||||
painter->setFont(nf);
|
||||
painter->drawText(cx - rect.width() - dx, cy, str.first);
|
||||
}
|
||||
}
|
||||
cy = real2canvasY(0.);
|
||||
if (cy >= 0 && cy <= (hei + 5)) {
|
||||
QPen _p(grid_pen);
|
||||
_p.setStyle(Qt::SolidLine);
|
||||
painter->setPen(_p);
|
||||
painter->drawLine(gbx, cy, cwid, cy);
|
||||
}
|
||||
if (hasLblY) {
|
||||
painter->setPen(text_color);
|
||||
painter->save();
|
||||
painter->translate(5, hei);
|
||||
painter->rotate(-90.);
|
||||
painter->drawText(0, 0, hei, font_sz.height(), Qt::AlignCenter, label_y);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
cy = chei - font_sz.height() / 4;
|
||||
if (hasLblX) cy -= font_sz.height();
|
||||
range = selrect.right() - selrect.left();
|
||||
QString df;
|
||||
if (axis_type_x == Graphic::Numeric) {
|
||||
if (grad_x == Graphic::Auto) step = splitRange(range, wid / gridx / font_sz.width() * 1.4);
|
||||
else step = gridx;//range / wid * gridx;
|
||||
start = roundTo(canvas2realX(wid), step) + step;
|
||||
px = start + step;
|
||||
if (step > 0.) {
|
||||
cnt = 1000;
|
||||
while (cnt-- > 0) {
|
||||
px -= step;
|
||||
if (fabs(px) < step * .5) px = 0.;
|
||||
cx = real2canvasX(px);
|
||||
if (cx > cwid) continue;
|
||||
if (cx < gbx) break;
|
||||
painter->setPen(grid_pen);
|
||||
painter->drawLine(cx, hei + 5, cx, 0);
|
||||
painter->setPen(text_color);
|
||||
int dx = -font_sz.height() / 4.;
|
||||
painter->setFont(nf);
|
||||
str = gridMark(px * grid_numbers_x);
|
||||
rect = fm.boundingRect(str.first);
|
||||
painter->drawText(cx + dx, cy, str.first);
|
||||
dx += rect.width() + font_sz.height() / 6.;
|
||||
if (!str.second.isEmpty()) {
|
||||
rect = sfm.boundingRect(str.second);
|
||||
painter->setFont(sf);
|
||||
painter->drawText(cx + dx, cy - font_sz.height() / 2.5, str.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
cx = real2canvasX(0.);
|
||||
if (cx <= cwid && cx >= gbx) {
|
||||
QPen _p(grid_pen);
|
||||
_p.setStyle(Qt::SolidLine);
|
||||
painter->setPen(_p);
|
||||
painter->drawLine(cx, hei + 5, cx, 0);
|
||||
}
|
||||
} else {
|
||||
int cur_scl[7] = {0,0,0,0,0,0,0};
|
||||
step = splitRangeDate(range, wid / gridx / font_sz.width() * 1.4, &df, cur_scl);
|
||||
start = roundTo(canvas2realX(wid), step) + step;
|
||||
px = start + step;
|
||||
QDateTime cd = QDateTime::fromMSecsSinceEpoch(px * grid_numbers_x);
|
||||
//qDebug() << "*** start" << cd << step;
|
||||
roundDateTime(cd, cur_scl);
|
||||
//qDebug() << "*** round" << cd;
|
||||
addDateTime(cd, cur_scl);
|
||||
//qDebug() << "*** add" << cd;
|
||||
//qDebug() << "*** cur" << cur_scl[0] << cur_scl[1] << cur_scl[2] << cur_scl[3] << cur_scl[4] << cur_scl[5] << cur_scl[6];
|
||||
if (step > 0.) {
|
||||
cnt = 1000;
|
||||
while (cnt-- > 0) {
|
||||
addDateTime(cd, cur_scl, -1);
|
||||
//roundDateTime(cd, cur_scl);
|
||||
//qDebug() << "next" << cd;
|
||||
cx = real2canvasX(cd.toMSecsSinceEpoch() / grid_numbers_x);
|
||||
if (cx > cwid) continue;
|
||||
if (cx < gbx) {/*qDebug() << cx << "<" << gbx;*/ break;}
|
||||
painter->setPen(grid_pen);
|
||||
painter->drawLine(cx, hei + 5, cx, 0);
|
||||
painter->setPen(text_color);
|
||||
int dx = -font_sz.height() / 4.;
|
||||
painter->setFont(nf);
|
||||
str.first = cd.toString(df);
|
||||
painter->drawText(cx + dx, cy, str.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
painter->setPen(text_color);
|
||||
painter->setFont(nf);
|
||||
if (hasLblX) {
|
||||
painter->setPen(text_color);
|
||||
painter->drawText(gbx, chei - font_sz.height(), wid, font_sz.height(), Qt::AlignCenter, label_x);
|
||||
}
|
||||
|
||||
painter->setPen(QPen(grid_pen.color(), thick));
|
||||
painter->drawRect(gbx, -1, wid + 6, hei + 6);
|
||||
}
|
||||
|
||||
|
||||
QPair<QString, QString> Graphic::gridMark(double v) const {
|
||||
QPair<QString, QString> ret;
|
||||
if ((qAbs(v) >= 1E+4 || qAbs(v) <= 1E-4) && v != 0.) {
|
||||
int p = qFloor(qLn(qAbs(v)) / LN10);
|
||||
v /= qPow(10., p);
|
||||
if (v == 10.) {
|
||||
v = 1.;
|
||||
p += 1;
|
||||
}
|
||||
ret.first = QString::fromUtf8("%1·10").arg(v);
|
||||
ret.second = QString::number(p);
|
||||
} else
|
||||
ret.first = QString::number(v);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::drawGraphics() {
|
||||
if (isHover)
|
||||
ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
|
||||
QPointF srp = -selrect.topLeft(), cp;
|
||||
double sclx, scly, wid = painter->viewport().width(), hei = painter->viewport().height() - legy, pw;
|
||||
sclx = (wid - gridborder.x() - margins_.left() - margins_.width()) / selrect.width();
|
||||
scly = (hei - gridborder.y() - margins_.top() - margins_.height()) / selrect.height();
|
||||
painter->setClipping(true);
|
||||
painter->setClipRect(QRect(gridborder.x(), 0, wid - gridborder.x(), hei - gridborder.y()));
|
||||
painter->translate(gridborder.x() + margins_.left(), hei - gridborder.y() - margins_.top());
|
||||
//if (isOGL && aalias) pen.setWidthF(1.5f);
|
||||
painter->scale(sclx, -scly);
|
||||
painter->translate(srp);
|
||||
QTransform mat = painter->transform();
|
||||
painter->resetTransform();
|
||||
painter->setWorldMatrixEnabled(false);
|
||||
QPolygonF cpol;
|
||||
for (int i = 0; i < graphics.size(); ++i) {
|
||||
GraphicType & t(graphics[i]);
|
||||
QPolygonF & rpol(pause_ ? t.polyline_pause : t.polyline);
|
||||
if (t.visible && !rpol.isEmpty()) {
|
||||
pw = t.pen.widthF();
|
||||
if (t.lines) {
|
||||
t.pen.setCosmetic(true);
|
||||
painter->setPen(t.pen);
|
||||
if (t.fill) {
|
||||
cpol = rpol;
|
||||
painter->setBrush(t.fill_color);
|
||||
//cpol.push_front(QPointF(cpol.front().x(), 0.));
|
||||
//cpol.push_back(QPointF(cpol.back().x(), 0.));
|
||||
painter->drawPolygon(mat.map(cpol));
|
||||
} else
|
||||
painter->drawPolyline(mat.map(rpol));
|
||||
}
|
||||
if (t.points) {
|
||||
if (qRound(t.pointWidth) == t.pointWidth) t.pen.setWidth(qRound(t.pointWidth));
|
||||
else t.pen.setWidthF(t.pointWidth);
|
||||
t.pen.setCosmetic(true);
|
||||
painter->setPen(t.pen);
|
||||
painter->drawPoints(mat.map(rpol));
|
||||
if (qRound(pw) == pw) t.pen.setWidth(qRound(pw));
|
||||
else t.pen.setWidthF(pw);
|
||||
}
|
||||
}
|
||||
}
|
||||
painter->setWorldMatrixEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
QString Graphic::pointCoords(QPointF point) {
|
||||
if (axis_type_x == Numeric)
|
||||
return "(" + QString::number(point.x(), 'f', 3) + " ; " + QString::number(point.y(), 'f', 3) + ")";
|
||||
return "(" + QDateTime::fromMSecsSinceEpoch(point.x()).toString() + " ; " + QString::number(point.y(), 'f', 3) + ")";
|
||||
}
|
||||
|
||||
|
||||
void Graphic::drawGuides() {
|
||||
if (!guides || !isHover) return;
|
||||
int wid = canvas->width(), hei = canvas->height();
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setPen(QPen(grid_pen.color(), qMax<int>(qRound(thick / 1.4), 1)));
|
||||
painter->resetTransform();
|
||||
painter->setClipping(true);
|
||||
painter->setClipRect(QRect(gridborder.x(), 0, wid - gridborder.x(), hei - gridborder.y()));
|
||||
painter->drawLine(0, curpos.y(), wid, curpos.y());
|
||||
painter->drawLine(curpos.x(), 0, curpos.x(), hei);
|
||||
QString str = pointCoords(canvas2real(curpos));
|
||||
QFontMetrics fm(font());
|
||||
QRect r = fm.boundingRect(str);
|
||||
QPoint p = curpos + QPoint(font_sz.height() / 4., -font_sz.height() / 4.);
|
||||
if (r.width() + curpos.x() > wid - font_sz.height() / 2.) p.setX(curpos.x() - r.width() - font_sz.height() / 4.);
|
||||
if (curpos.y() - r.height() < font_sz.height() / 8.) p.setY(curpos.y() + r.height() - font_sz.height() / 8.);
|
||||
painter->setPen(text_color);
|
||||
painter->drawText(p, str);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::drawPause() {
|
||||
painter->setClipping(false);
|
||||
painter->save();
|
||||
painter->resetMatrix();
|
||||
painter->translate(canvas->width() - icon_pause_b.width() - 6, 6);
|
||||
double o = (0.5 - pause_phase) * 2;
|
||||
painter->setOpacity(o*o);
|
||||
painter->drawImage(0, 0, icon_pause_b);
|
||||
painter->setOpacity(1.);
|
||||
painter->drawImage(0, 0, icon_pause_f);
|
||||
painter->restore();
|
||||
painter->setClipping(true);
|
||||
}
|
||||
|
||||
|
||||
double Graphic::splitRange(double range, int count) {
|
||||
double digits, step, tln;
|
||||
range = qAbs<double>(range);
|
||||
tln = qFloor(qLn(range) / LN10);
|
||||
for (int i = 0; i <= 5; ++i) {
|
||||
digits = qPow(10., tln - i);
|
||||
step = qRound(range / count / digits);
|
||||
if (step > 0.) {
|
||||
digits = qPow(10., tln - i - 1);
|
||||
step = qRound(range / count / digits);
|
||||
break;
|
||||
}
|
||||
}
|
||||
double step5 = qRound(step / 5.) * 5., step10 = qRound(step / 10.) * 10.;
|
||||
double err5 = qAbs<double>(step - step5), err10 = qAbs<double>(step - step10);
|
||||
step = (err5 < err10 ? step5 : step10) * digits;
|
||||
return step;
|
||||
}
|
||||
|
||||
|
||||
double Graphic::splitRangeDate(double range, int count, QString * format, int step[7]) {
|
||||
double ret = splitRange(range, count);
|
||||
//qDebug() << "ret =" << ret << getScaleX();
|
||||
if (ret < 1000. * 1) {*format = "ss.zzz"; step[0] = ret;}
|
||||
else if (ret < 1000. * 60) {*format = "h:m:ss"; step[1] = qRound(ret / 1000);}
|
||||
else if (ret < 1000. * 60 * 60) {*format = "h:mm"; step[2] = qRound(ret / 1000 / 60);}
|
||||
else if (ret < 1000. * 60 * 60 * 24) {*format = "dd(ddd) hh"; step[3] = qRound(ret / 1000 / 60 / 60);}
|
||||
else if (ret < 1000. * 60 * 60 * 24 * 30) {*format = "MMM dd"; step[4] = qRound(ret / 1000 / 60 / 60 / 24);}
|
||||
else if (ret < 1000. * 60 * 60 * 24 * 30 * 12) {*format = "yyyy MMM"; step[5] = qRound(ret / 1000 / 60 / 60 / 24 / 30);}
|
||||
else {*format = "yyyy"; step[6] = qRound(ret / 1000 / 60 / 60 / 24 / 30 / 12);}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
double Graphic::roundTo(double value, double round_to) {
|
||||
if (round_to == 0.) return value;
|
||||
return qRound(value / round_to) * round_to;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::roundDateTime(QDateTime & dt, int c[7]) {
|
||||
QDate d(dt.date()); QTime t(dt.time());
|
||||
//if (c[0] != 0) t.setHMS(t.hour(), t.minute(), t.second(), 0);
|
||||
if (c[1] != 0) t.setHMS(t.hour(), t.minute(), t.second());
|
||||
if (c[2] != 0) t.setHMS(t.hour(), t.minute(), 0);
|
||||
if (c[3] != 0) t.setHMS(t.hour(), 0, 0);
|
||||
if (c[4] != 0) {t.setHMS(0, 0, 0); d.setDate(d.year(), d.month(), d.day());}
|
||||
if (c[5] != 0) {t.setHMS(0, 0, 0); d.setDate(d.year(), d.month(), 1);}
|
||||
if (c[6] != 0) {t.setHMS(0, 0, 0); d.setDate(d.year(), 1, 1);}
|
||||
dt = QDateTime(d, t);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::addDateTime(QDateTime & dt, int c[7], int mul) {
|
||||
if (c[0] != 0) dt = dt.addMSecs(mul * c[0]);
|
||||
if (c[1] != 0) dt = dt.addSecs(mul * c[1]);
|
||||
if (c[2] != 0) dt = dt.addSecs(mul * c[2] * 60);
|
||||
if (c[3] != 0) dt = dt.addSecs(mul * c[3] * 60 * 60);
|
||||
if (c[4] != 0) dt = dt.addDays(mul * c[4]);
|
||||
if (c[5] != 0) dt = dt.addMonths(mul * c[5]);
|
||||
if (c[6] != 0) dt = dt.addYears(mul * c[6]);
|
||||
}
|
||||
|
||||
|
||||
double Graphic::canvas2realX(double px) const {
|
||||
int gbx = gridborder.x() + margins_.left(), cwid = lastw, wid = cwid - gbx - margins_.width();
|
||||
double cx = px - gbx, sclx = selrect.width() / (double)wid;
|
||||
return cx * sclx + selrect.x();
|
||||
}
|
||||
|
||||
|
||||
double Graphic::canvas2realY(double py) const {
|
||||
int gby = gridborder.y() + margins_.top(), chei = lasth - legy, hei = chei - gby - margins_.height();
|
||||
double cy = chei - py - gby, scly = selrect.height() / (double)hei;
|
||||
return cy * scly + selrect.y();
|
||||
}
|
||||
|
||||
|
||||
double Graphic::real2canvasX(double px) const {
|
||||
int gbx = gridborder.x() + margins_.left(), cwid = lastw, wid = cwid - gbx - margins_.width();
|
||||
double sclx = selrect.width() / (double)wid;
|
||||
return (px - selrect.x()) / sclx + gbx;
|
||||
}
|
||||
|
||||
|
||||
double Graphic::real2canvasY(double py) const {
|
||||
int gby = gridborder.y() + margins_.top(), chei = lasth - legy, hei = chei - gby - margins_.height();
|
||||
double scly = selrect.height() / (double)hei;
|
||||
return chei - gby - (py - selrect.y()) / scly;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setCurrentAction(GraphicAction action) {
|
||||
curaction = action;
|
||||
switch (action) {
|
||||
case gaNone:
|
||||
if (guides) setCanvasCursor(Qt::BlankCursor);
|
||||
else setCanvasCursor(Qt::ArrowCursor);
|
||||
break;
|
||||
case gaZoomInRect:
|
||||
setCanvasCursor(Qt::CrossCursor);
|
||||
break;
|
||||
case gaZoomRangeX:
|
||||
setCanvasCursor(Qt::SplitHCursor);
|
||||
break;
|
||||
case gaZoomRangeY:
|
||||
setCanvasCursor(Qt::SplitVCursor);
|
||||
break;
|
||||
case gaMove:
|
||||
setCanvasCursor(Qt::SizeAllCursor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setCanvasCursor(QCursor cursor) {
|
||||
ui->canvas_raster->setCursor(cursor);
|
||||
ui->canvas_gl->setCursor(cursor);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::swapToBuffer() {
|
||||
QImage timg;
|
||||
//qDebug() << "render start";
|
||||
if (isOGL) {
|
||||
timg = ui->canvas_gl->grabFrameBuffer();
|
||||
QPainter p(buffer);
|
||||
p.drawImage(0, 0, timg);
|
||||
p.end();
|
||||
}
|
||||
//qDebug() << "render finish";
|
||||
bufferActive = true;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setRectToLines() {
|
||||
is_lines_update = true;
|
||||
line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = true;
|
||||
//qDebug() << "set to lines" << selrect;
|
||||
line_x_min.is_reset = line_x_max.is_reset = line_y_min.is_reset = line_y_max.is_reset = isFit;
|
||||
if (!line_x_min.hasFocus()) line_x_min.setValue(selrect.left());
|
||||
if (!line_x_max.hasFocus()) line_x_max.setValue(selrect.right());
|
||||
if (!line_y_min.hasFocus()) line_y_min.setValue(selrect.bottom());
|
||||
if (!line_y_max.hasFocus()) line_y_max.setValue(selrect.top());
|
||||
if (!isFit) {
|
||||
line_x_min.setDefaultText(QString::number(grect.left()).toUpper());
|
||||
line_x_max.setDefaultText(QString::number(grect.right()).toUpper());
|
||||
line_y_min.setDefaultText(QString::number(grect.bottom()).toUpper());
|
||||
line_y_max.setDefaultText(QString::number(grect.top()).toUpper());
|
||||
}
|
||||
line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = false;
|
||||
is_lines_update = false;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::checkLines() {
|
||||
isFit = (line_x_min.isDefault() && line_x_max.isDefault() && line_y_min.isDefault() && line_y_max.isDefault());
|
||||
update(true);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::tick(int index, bool slide, bool update_) {
|
||||
if (slide) {
|
||||
mutex.lock();
|
||||
GraphicType & t(graphics[index]);
|
||||
if (history > 0.)
|
||||
while (t.polyline.size() > 1) {
|
||||
if (fabs(t.polyline.back().x() - t.polyline.front().x()) <= history) break;
|
||||
t.polyline.pop_front();
|
||||
}
|
||||
}
|
||||
if (!update_) {
|
||||
if (isFit) findGraphicsRect();
|
||||
mutex.unlock();
|
||||
return;
|
||||
}
|
||||
//polyline.push_back(QPointF(brick->time_, brick->output(port)));
|
||||
//cout << polyline.size() << endl;
|
||||
if (isFit) findGraphicsRect();
|
||||
if (!slide) {
|
||||
if (aupdate) update();
|
||||
return;
|
||||
}
|
||||
mutex.unlock();
|
||||
if (aupdate) update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::on_buttonAutofit_clicked() {
|
||||
isFit = true;
|
||||
bool isEmpty = true;
|
||||
foreach (const GraphicType & t, graphics) {
|
||||
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
|
||||
if (!pol.isEmpty()) {
|
||||
isEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isEmpty) grect = def_rect;
|
||||
selrect = grect;
|
||||
findGraphicsRect();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::on_buttonConfigure_clicked() {
|
||||
conf->graphicItems.clear();
|
||||
for (int i = 0; i < graphics.size(); i++) {
|
||||
GraphicConf::GraphicItem item;
|
||||
item.icon = graphics[i].icon;
|
||||
item.name = graphics[i].name;
|
||||
conf->graphicItems.append(item);
|
||||
}
|
||||
conf->ui->colorGrid->setColor(grid_pen.color());
|
||||
conf->ui->comboStyleGrid->setCurrentIndex((int)grid_pen.style());
|
||||
conf->ui->spinWidthGrid->setValue(grid_pen.widthF());
|
||||
conf->ui->checkOGL->setChecked(isOGL);
|
||||
conf->ui->checkAAlias->setChecked(aalias);
|
||||
conf->ui->checkInputs->setChecked(borderInputsVisible());
|
||||
conf->ui->checkStatus->setChecked(statusVisible());
|
||||
conf->ui->checkLegend->setChecked(legendVisible());
|
||||
conf->ui->checkGridAutoX->setChecked(grad_x == Auto);
|
||||
conf->ui->checkGridAutoY->setChecked(grad_y == Auto);
|
||||
conf->ui->colorBackground->setColor(back_color);
|
||||
conf->ui->colorText->setColor(text_color);
|
||||
conf->ui->spinGridStepX->setValue(gridx);
|
||||
conf->ui->spinGridStepY->setValue(gridy);
|
||||
conf->ui->spinMarginL->setValue(margins_.left());
|
||||
conf->ui->spinMarginT->setValue(margins_.height());
|
||||
conf->ui->spinMarginR->setValue(margins_.width());
|
||||
conf->ui->spinMarginB->setValue(margins_.top());
|
||||
conf->readParams();
|
||||
if (conf->exec() == QDialog::Rejected) return;
|
||||
grid_pen = QPen(conf->ui->colorGrid->color(), conf->ui->spinWidthGrid->value(), (Qt::PenStyle)conf->ui->comboStyleGrid->currentIndex());
|
||||
back_color = conf->ui->colorBackground->color();
|
||||
text_color = conf->ui->colorText->color();
|
||||
grad_x = conf->ui->checkGridAutoX->isChecked() ? Auto : Fixed;
|
||||
grad_y = conf->ui->checkGridAutoY->isChecked() ? Auto : Fixed;
|
||||
gridx = conf->ui->spinGridStepX->value();
|
||||
gridy = conf->ui->spinGridStepY->value();
|
||||
setOpenGL(conf->ui->checkOGL->isChecked());
|
||||
setAntialiasing(conf->ui->checkAAlias->isChecked());
|
||||
setBorderInputsVisible(conf->ui->checkInputs->isChecked());
|
||||
setStatusVisible(conf->ui->checkStatus->isChecked());
|
||||
setLegendVisible(conf->ui->checkLegend->isChecked());
|
||||
setMargins(conf->ui->spinMarginL->value(), conf->ui->spinMarginR->value(), conf->ui->spinMarginT->value(), conf->ui->spinMarginB->value());
|
||||
updateLegend();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::on_checkGuides_toggled(bool checked) {
|
||||
guides = checked;
|
||||
if (guides) setCanvasCursor(Qt::BlankCursor);
|
||||
else setCanvasCursor(Qt::ArrowCursor);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::updateLegend() {
|
||||
if (!ui->widgetLegend->isVisible()) return;
|
||||
leg_update = false;
|
||||
int ps = 100;
|
||||
for (int i = 0; i < graphics.size(); i++) {
|
||||
while (!graphics[i].pb->actions().isEmpty()) graphics[i].pb->removeAction(graphics[i].pb->actions()[0]);
|
||||
delete graphics[i].pb;
|
||||
QPixmap pix(60, 22);
|
||||
pix.fill(back_color);
|
||||
QPainter p(&pix);
|
||||
p.setPen(graphics[i].pen);
|
||||
p.drawLine(0, pix.height() / 2, pix.width(), pix.height() / 2);
|
||||
p.end();
|
||||
graphics[i].icon = QIcon(pix);
|
||||
graphics[i].pb = new QCheckBox(graphics[i].name);
|
||||
graphics[i].pb->setIconSize(pix.size());
|
||||
//graphics[i].pb->setFlat(true);
|
||||
graphics[i].pb->setIcon(graphics[i].icon);
|
||||
graphics[i].pb->setChecked(graphics[i].visible);
|
||||
graphics[i].pb->setProperty("graphic_num", i);
|
||||
graphics[i].pb->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
//qDebug() << graphics[i].pb->actions();
|
||||
QAction * act = new QAction(trUtf8("Check all"), 0);
|
||||
act->setCheckable(true);
|
||||
act->setChecked(true);
|
||||
graphics[i].pb->addAction(act);
|
||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(graphicAllVisibleChange(bool)));
|
||||
connect(graphics[i].pb, SIGNAL(toggled(bool)), this, SLOT(graphicVisibleChange(bool)));
|
||||
int cps = graphics[i].pb->sizeHint().width() + 4;
|
||||
if (cps > ps) ps = cps;
|
||||
}
|
||||
int maxcol = qMax<int>(ui->widgetLegend->width() / ps - 1, 1);
|
||||
int row = 0, col = 0;
|
||||
bool lv = ui->widgetLegend->isVisible();
|
||||
ui->widgetLegend->hide();
|
||||
for (int i = 0; i < graphics.size(); i++) {
|
||||
ui->layoutLegend->addWidget(graphics[i].pb,row,col);
|
||||
col++;
|
||||
if (col > maxcol) {col = 0; row++;}
|
||||
}
|
||||
ui->widgetLegend->setVisible(lv);
|
||||
leg_update = true;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::graphicVisibleChange(bool checked) {
|
||||
if (visible_update) return;
|
||||
QCheckBox * cb = qobject_cast<QCheckBox*>(sender());
|
||||
int i = cb->property("graphic_num").toInt();
|
||||
graphics[i].visible = checked;
|
||||
if (isFit) on_buttonAutofit_clicked();
|
||||
else update();
|
||||
// update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::graphicAllVisibleChange(bool checked) {
|
||||
visible_update = true;
|
||||
for (int i=0; i<graphics.size(); i++) {
|
||||
graphics[i].visible = checked;
|
||||
graphics[i].pb->setChecked(checked);
|
||||
}
|
||||
visible_update = false;
|
||||
if (isFit) on_buttonAutofit_clicked();
|
||||
else update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::enterFullscreen() {
|
||||
if (fullscr) return;
|
||||
ui->layoutCanvas->removeWidget(canvas);
|
||||
canvas->setParent(0);
|
||||
canvas->showFullScreen();
|
||||
canvas->setFocus();
|
||||
canvas->raise();
|
||||
fullscr = true;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::leaveFullscreen() {
|
||||
if (!fullscr) return;
|
||||
canvas->setWindowFlags(canvas->windowFlags() & ~Qt::WindowFullScreen);
|
||||
ui->layoutCanvas->addWidget(canvas);
|
||||
canvas->show();
|
||||
fullscr = false;
|
||||
}
|
||||
|
||||
|
||||
QString Graphic::caption() const {
|
||||
return ui->labelCaption->text();
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::borderInputsVisible() const {
|
||||
return ui->widgetLX->isVisible();
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::statusVisible() const {
|
||||
return ui->status->isVisible();
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::legendVisible() const {
|
||||
return ui->widgetLegend->isVisible();
|
||||
}
|
||||
|
||||
|
||||
QByteArray Graphic::save() {
|
||||
QByteArray ba;
|
||||
QDataStream s(&ba, QIODevice::ReadWrite);
|
||||
s << openGL() << antialiasing() << borderInputsVisible() << statusVisible() << legendVisible();
|
||||
s << graphics;
|
||||
return ba;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::load(QByteArray ba) {
|
||||
if (ba.isEmpty()) return;
|
||||
QDataStream s(ba);
|
||||
bool a;
|
||||
s >> a; setOpenGL(a);
|
||||
s >> a; setAntialiasing(a);
|
||||
s >> a; setBorderInputsVisible(a);
|
||||
s >> a; setStatusVisible(a);
|
||||
s >> a; setLegendVisible(a);
|
||||
s >> graphics;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setCaption(const QString & str) {
|
||||
ui->labelCaption->setText(str);
|
||||
ui->labelCaption->setVisible(str.length() > 0);
|
||||
if (aupdate) update();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setGridEnabled(bool enabled) {
|
||||
ui->checkGrid->setChecked(enabled);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setBorderInputsVisible(bool visible) {
|
||||
ui->widgetLX->setVisible(visible);
|
||||
ui->widgetLY->setVisible(visible);
|
||||
ui->checkBorderInputs->setChecked(visible);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setStatusVisible(bool visible) {
|
||||
ui->status->setVisible(visible);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setLegendVisible(bool visible) {
|
||||
ui->widgetLegend->setVisible(visible);
|
||||
ui->checkLegend->setChecked(visible);
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
|
||||
void Graphic::on_checkExpandY_toggled(bool checked) {
|
||||
only_expand_y = checked;
|
||||
ui->checkExpandY->setIcon(checked ? icon_exp_y : icon_exp_sy);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::on_checkExpandX_toggled(bool checked) {
|
||||
only_expand_x = checked;
|
||||
ui->checkExpandX->setIcon(checked ? icon_exp_x : icon_exp_sx);
|
||||
}
|
||||
459
qad/graphic/graphic.h
Normal file
459
qad/graphic/graphic.h
Normal file
@@ -0,0 +1,459 @@
|
||||
#ifndef GRAPHIC_H
|
||||
#define GRAPHIC_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QMouseEvent>
|
||||
#include <QComboBox>
|
||||
#include <QMutex>
|
||||
#include <QDebug>
|
||||
#include <QGridLayout>
|
||||
#include <QFileDialog>
|
||||
#include <QTime>
|
||||
#include <QTranslator>
|
||||
#include <QGestureEvent>
|
||||
#include <qmath.h>
|
||||
#include <float.h>
|
||||
#include "graphic_conf.h"
|
||||
#include "clineedit.h"
|
||||
#include "qpievaluator.h"
|
||||
#if QT_VERSION >= 0x050100
|
||||
# include <QSensorGestureManager>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class ELineEdit: public CLineEdit {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ELineEdit(QWidget * parent = 0);
|
||||
//void setText(const QString & v) {if (!is_auto) is_reset = false; CLineEdit::setText(v); setDefaultText(v, is_reset); last_ret = complexd(v.toDouble(), 0.); emit valueChanged(last_ret.real());}
|
||||
void setValue(const int & v) {if (is_reset) setDefaultText(QString::number(v).toUpper(), is_reset); else setText(QString::number(v).toUpper()); last_ret = complexd(v, 0.); if (!is_auto) emit valueChanged(last_ret.real());}
|
||||
void setValue(const double & v) {if (is_reset) setDefaultText(QString::number(v).toUpper(), is_reset); else setText(QString::number(v).toUpper()); last_ret = complexd(v, 0.); if (!is_auto) emit valueChanged(last_ret.real());}
|
||||
double value() const {return last_ret.real();}
|
||||
bool isDefault() const {return !cw->isVisible();}
|
||||
bool is_reset, is_auto;
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent * e);
|
||||
QPIEvaluator evaluator;
|
||||
complexd last_ret;
|
||||
private slots:
|
||||
void toDefaultClicked() {is_reset = true; calculate();}
|
||||
void calculate();
|
||||
signals:
|
||||
void valueChanged(double value);
|
||||
};
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class Graphic;
|
||||
};
|
||||
|
||||
|
||||
class Graphic: public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_FLAGS(Buttons)
|
||||
Q_ENUMS(Alignment Graduation AxisType)
|
||||
|
||||
Q_PROPERTY(QString caption READ caption WRITE setCaption)
|
||||
Q_PROPERTY(QString labelX READ labelX WRITE setLabelX)
|
||||
Q_PROPERTY(QString labelY READ labelY WRITE setLabelY)
|
||||
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
|
||||
Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
|
||||
|
||||
Q_PROPERTY(int currentGraphic READ currentGraphic WRITE setCurrentGraphic)
|
||||
Q_PROPERTY(int graphicsCount READ graphicsCount WRITE setGraphicsCount)
|
||||
Q_PROPERTY(QString graphicName READ graphicName WRITE setGraphicName)
|
||||
Q_PROPERTY(QPen graphicPen READ graphicPen WRITE setGraphicPen)
|
||||
Q_PROPERTY(QColor graphicColor READ graphicColor WRITE setGraphicColor)
|
||||
Q_PROPERTY(Qt::PenStyle graphicStyle READ graphicStyle WRITE setGraphicStyle)
|
||||
Q_PROPERTY(double graphicLineWidth READ graphicLineWidth WRITE setGraphicLineWidth)
|
||||
Q_PROPERTY(double graphicPointWidth READ graphicPointWidth WRITE setGraphicPointWidth)
|
||||
Q_PROPERTY(QColor graphicFillColor READ graphicFillColor WRITE setGraphicFillColor)
|
||||
Q_PROPERTY(bool graphicLinesEnabled READ graphicLinesEnabled WRITE setGraphicLinesEnabled)
|
||||
Q_PROPERTY(bool graphicPointsEnabled READ graphicPointsEnabled WRITE setGraphicPointsEnabled)
|
||||
Q_PROPERTY(bool graphicFillEnabled READ graphicFillEnabled WRITE setGraphicFillEnabled)
|
||||
|
||||
Q_PROPERTY(bool gridEnabled READ gridEnabled WRITE setGridEnabled)
|
||||
Q_PROPERTY(QPen gridPen READ gridPen WRITE setGridPen)
|
||||
Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor)
|
||||
Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle)
|
||||
|
||||
Q_PROPERTY(QPen selectionPen READ selectionPen WRITE setSelectionPen)
|
||||
Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor)
|
||||
Q_PROPERTY(Qt::PenStyle selectionStyle READ selectionStyle WRITE setSelectionStyle)
|
||||
Q_PROPERTY(QBrush selectionBrush READ selectionBrush WRITE setSelectionBrush)
|
||||
|
||||
Q_PROPERTY(Alignment buttonsPosition READ buttonsPosition WRITE setButtonsPosition)
|
||||
Q_PROPERTY(Buttons buttons READ buttons WRITE setButtons)
|
||||
Q_PROPERTY(bool navigationEnabled READ navigationEnabled WRITE setNavigationEnabled)
|
||||
Q_PROPERTY(bool openGL READ openGL WRITE setOpenGL)
|
||||
Q_PROPERTY(bool antialiasing READ antialiasing WRITE setAntialiasing)
|
||||
Q_PROPERTY(bool autoUpdate READ autoUpdate WRITE setAutoUpdate)
|
||||
Q_PROPERTY(bool borderInputsVisible READ borderInputsVisible WRITE setBorderInputsVisible)
|
||||
Q_PROPERTY(bool statusVisible READ statusVisible WRITE setStatusVisible)
|
||||
Q_PROPERTY(bool legendVisible READ legendVisible WRITE setLegendVisible)
|
||||
Q_PROPERTY(bool paused READ paused WRITE setPaused)
|
||||
Q_PROPERTY(bool onlyExpandY READ onlyExpandY WRITE setOnlyExpandY)
|
||||
Q_PROPERTY(bool onlyExpandX READ onlyExpandX WRITE setOnlyExpandX)
|
||||
Q_PROPERTY(double historySize READ historySize WRITE setHistorySize)
|
||||
Q_PROPERTY(double maxVisibleTime READ maxVisibleTime WRITE setMaxVisibleTime)
|
||||
Q_PROPERTY(double autoXIncrement READ autoXIncrement WRITE setAutoXIncrement)
|
||||
Q_PROPERTY(QRectF limit READ limit WRITE setLimit)
|
||||
Q_PROPERTY(QRect margins READ margins WRITE setMargins)
|
||||
Q_PROPERTY(QRectF visualRect READ visualRect WRITE setVisualRect)
|
||||
Q_PROPERTY(QRectF defaultRect READ defaultRect WRITE setDefaultRect)
|
||||
Q_PROPERTY(int minimumRepaintInterval READ minimumRepaintInterval WRITE setMinimumRepaintInterval)
|
||||
|
||||
Q_PROPERTY(double gridNumbersMultiplierX READ gridNumbersMultiplierX WRITE setGridNumbersMultiplierX)
|
||||
Q_PROPERTY(double gridNumbersMultiplierY READ gridNumbersMultiplierY WRITE setGridNumbersMultiplierY)
|
||||
Q_PROPERTY(Graduation graduationX READ graduationX WRITE setGraduationX)
|
||||
Q_PROPERTY(Graduation graduationY READ graduationY WRITE setGraduationY)
|
||||
Q_PROPERTY(double graduationStepX READ graduationStepX WRITE setGraduationStepX)
|
||||
Q_PROPERTY(double graduationStepY READ graduationStepY WRITE setGraduationStepY)
|
||||
Q_PROPERTY(AxisType axisType READ axisType WRITE setAxisType)
|
||||
|
||||
Q_PROPERTY(int histogramMinIntervals READ histogramMinIntervals WRITE setHistogramMinIntervals)
|
||||
Q_PROPERTY(int histogramMaxIntervals READ histogramMaxIntervals WRITE setHistogramMaxIntervals)
|
||||
Q_PROPERTY(double histogramMinDeltaMultiplier READ histogramMinDeltaMultiplier WRITE setHistogramMinDeltaMultiplier)
|
||||
|
||||
Q_PROPERTY(Graphic::GraphicsData graphicsData READ graphicsData WRITE setGraphicsData)
|
||||
|
||||
public:
|
||||
Graphic(QWidget * parent = 0);
|
||||
~Graphic();
|
||||
|
||||
typedef QVector<QVector<QPointF> > GraphicsData;
|
||||
enum GraphicAction {gaNone, gaZoomInRect, gaZoomRangeX, gaZoomRangeY, gaMove};
|
||||
enum Button {NoButtons = 0x0,
|
||||
AllButtons = 0xFFFFFFFF,
|
||||
Autofit = 0x01,
|
||||
Grid = 0x02,
|
||||
CursorAxis = 0x04,
|
||||
OnlyExpandY = 0x08,
|
||||
OnlyExpandX = 0x10,
|
||||
Fullscreen = 0x20,
|
||||
BorderInputs = 0x40,
|
||||
Legend = 0x80,
|
||||
Configure = 0x100,
|
||||
Save = 0x200,
|
||||
Clear = 0x800,
|
||||
Close = 0x1000,
|
||||
Pause = 0x2000
|
||||
};
|
||||
enum Alignment {Left, Right};
|
||||
enum Graduation {Auto, Fixed};
|
||||
enum AxisType {Numeric, DateTime};
|
||||
Q_DECLARE_FLAGS(Buttons, Button)
|
||||
|
||||
QString caption() const;
|
||||
QString labelX() const {return label_x;}
|
||||
QString labelY() const {return label_y;}
|
||||
QString graphicName() const {return graphics[curGraphic].name;}
|
||||
QColor backgroundColor() const {return back_color;}
|
||||
QColor textColor() const {return text_color;}
|
||||
QColor graphicColor() const {return graphics[curGraphic].pen.color();}
|
||||
QColor gridColor() const {return grid_pen.color();}
|
||||
QColor selectionColor() const {return selpen.color();}
|
||||
Qt::PenStyle graphicStyle() const {return graphics[curGraphic].pen.style();}
|
||||
Qt::PenStyle gridStyle() const {return grid_pen.style();}
|
||||
Qt::PenStyle selectionStyle() const {return selpen.style();}
|
||||
double graphicLineWidth() const {return graphics[curGraphic].pen.widthF();}
|
||||
double graphicPointWidth() const {return graphics[curGraphic].pointWidth;}
|
||||
QColor graphicFillColor() const {return graphics[curGraphic].fill_color;}
|
||||
bool graphicVisible() const {return graphics[curGraphic].visible;}
|
||||
bool graphicLinesEnabled() const {return graphics[curGraphic].lines;}
|
||||
bool graphicPointsEnabled() const {return graphics[curGraphic].points;}
|
||||
bool graphicFillEnabled() const {return graphics[curGraphic].fill;}
|
||||
QPen graphicPen() const {return graphics[curGraphic].pen;}
|
||||
QPen gridPen() const {return grid_pen;}
|
||||
QPen selectionPen() const {return selpen;}
|
||||
QBrush selectionBrush() const {return selbrush;}
|
||||
bool navigationEnabled() const {return navigation;}
|
||||
bool openGL() const {return isOGL;}
|
||||
bool antialiasing() const {return aalias;}
|
||||
bool autoUpdate() const {return aupdate;}
|
||||
bool gridEnabled() const {return grid;}
|
||||
bool borderInputsVisible() const;
|
||||
bool statusVisible() const;
|
||||
bool legendVisible() const;
|
||||
bool paused() const {return pause_;}
|
||||
bool onlyExpandY() const {return only_expand_y;}
|
||||
bool onlyExpandX() const {return only_expand_x;}
|
||||
int currentGraphic() const {return curGraphic;}
|
||||
int graphicsCount() const {return graphics.size();}
|
||||
Graphic::Buttons buttons() const {return buttons_;}
|
||||
Graphic::Alignment buttonsPosition() const {return align;}
|
||||
double historySize() const {return history;}
|
||||
double maxVisibleTime() const {return visible_time;}
|
||||
double autoXIncrement() const {return inc_x;}
|
||||
QRectF visualRect() const {return selrect;}
|
||||
QRectF defaultRect() const {return def_rect;}
|
||||
QRectF limit() const {return limit_;}
|
||||
QRect margins() const {return margins_;}
|
||||
int minimumRepaintInterval() const {return min_repaint_int;}
|
||||
int histogramMinIntervals() const {return min_int;}
|
||||
int histogramMaxIntervals() const {return max_int;}
|
||||
double histogramMinDeltaMultiplier() const {return mdm;}
|
||||
double gridNumbersMultiplierX() const {return grid_numbers_x;}
|
||||
double gridNumbersMultiplierY() const {return grid_numbers_y;}
|
||||
Graduation graduationX() const {return grad_x;}
|
||||
Graduation graduationY() const {return grad_y;}
|
||||
double graduationStepX() const {return gridx;}
|
||||
double graduationStepY() const {return gridy;}
|
||||
AxisType axisType() const {return axis_type_x;}
|
||||
QVector<QPointF> graphicData(const int index = 0) const {return graphics[index].polyline;}
|
||||
GraphicsData graphicsData() const;
|
||||
QWidget * viewport() const {return canvas;}
|
||||
QByteArray save();
|
||||
void load(QByteArray ba);
|
||||
void lock() {mutex_.lock();}
|
||||
void unlock() {mutex_.unlock();}
|
||||
|
||||
void reset() {mutex.lock(); clear(); mutex.unlock();}
|
||||
|
||||
GraphicType graphic(int arg) {if (arg < 0 || arg >= graphics.size()) return GraphicType(); return graphics[arg];}
|
||||
const QVector<GraphicType> & allGraphics() const {return graphics;}
|
||||
void setAllGraphics(const QVector<GraphicType> & g, bool update = true) {graphics = g; if (update) updateLegend();}
|
||||
void setHistogramData(const QVector<float> & g, int graphic);
|
||||
void setHistogramData(const QVector<float> & g) {setHistogramData(g, curGraphic);}
|
||||
|
||||
double canvas2realX(double px) const;
|
||||
double canvas2realY(double py) const;
|
||||
double real2canvasX(double px) const;
|
||||
double real2canvasY(double py) const;
|
||||
QPointF canvas2real(QPointF canvas_point) const {return QPointF(canvas2realX(canvas_point.x()), canvas2realY(canvas_point.y()));}
|
||||
QPointF real2canvas(QPointF real_point) const {return QPointF(real2canvasX(real_point.x()), real2canvasY(real_point.y()));}
|
||||
double getScaleX() const {return real2canvasX(1.) - real2canvasX(0.);}
|
||||
double getScaleY() const {return real2canvasY(1.) - real2canvasY(0.);}
|
||||
QPointF getScale() const {return QPointF(getScaleX(), getScaleY());}
|
||||
|
||||
public slots:
|
||||
void setCaption(const QString & str);
|
||||
void setLabelX(const QString & str) {label_x = str; hasLblX = (str.length() > 0); if (aupdate) update();}
|
||||
void setLabelY(const QString & str) {label_y = str; hasLblY = (str.length() > 0); if (aupdate) update();}
|
||||
void setGraphicName(const QString & str, int index) {graphics[index].name = str; updateLegend(); if (aupdate) update();}
|
||||
void setGraphicName(const QString & str) {graphics[curGraphic].name = str; updateLegend(); if (aupdate) update();}
|
||||
void setBackgroundColor(const QColor & color) {back_color = color; if (aupdate) update(); updateLegend();}
|
||||
void setTextColor(const QColor & color) {text_color = color; if (aupdate) update();}
|
||||
void setGraphicColor(const QColor & color, int index) {graphics[index].pen.setColor(color); updateLegend(); if (aupdate) update();}
|
||||
void setGraphicColor(const QColor & color) {setGraphicColor(color, curGraphic);}
|
||||
void setGridColor(const QColor & color) {grid_pen.setColor(color); if (aupdate) update();}
|
||||
void setSelectionColor(const QColor & color) {selpen.setColor(color);}
|
||||
void setGraphicStyle(const Qt::PenStyle & style) {graphics[curGraphic].pen.setStyle(style); updateLegend(); if (aupdate) update();}
|
||||
void setGridStyle(const Qt::PenStyle & style) {grid_pen.setStyle(style); if (aupdate) update();}
|
||||
void setSelectionStyle(const Qt::PenStyle & style) {selpen.setStyle(style);}
|
||||
void setGraphicVisible(bool visible, int index) {graphics[index].visible = visible; updateLegend(); if (aupdate) update();}
|
||||
void setGraphicVisible(bool visible) {setGraphicVisible(visible, curGraphic);}
|
||||
void setGraphicLineWidth(double w, int index) {if (qRound(w) == w) graphics[index].pen.setWidth(qRound(w)); else graphics[index].pen.setWidthF(w); updateLegend(); if (aupdate) update();}
|
||||
void setGraphicLineWidth(double w) {setGraphicLineWidth(w, curGraphic);}
|
||||
void setGraphicPointWidth(double w, int index) {graphics[index].pointWidth = w; updateLegend(); if (aupdate) update();}
|
||||
void setGraphicPointWidth(double w) {setGraphicPointWidth(w, curGraphic);}
|
||||
void setGraphicFillColor(const QColor & w, int index) {graphics[index].fill_color = w; updateLegend(); if (aupdate) update();}
|
||||
void setGraphicFillColor(const QColor & w) {setGraphicFillColor(w, curGraphic);}
|
||||
void setGraphicLinesEnabled(bool w, int index) {graphics[index].lines = w; updateLegend(); if (aupdate) update();}
|
||||
void setGraphicLinesEnabled(bool w) {setGraphicLinesEnabled(w, curGraphic);}
|
||||
void setGraphicPointsEnabled(bool w, int index) {graphics[index].points = w; updateLegend(); if (aupdate) update();}
|
||||
void setGraphicPointsEnabled(bool w) {setGraphicPointsEnabled(w, curGraphic);}
|
||||
void setGraphicFillEnabled(bool w, int index) {graphics[index].fill = w; updateLegend(); if (aupdate) update();}
|
||||
void setGraphicFillEnabled(bool w) {setGraphicFillEnabled(w, curGraphic);}
|
||||
void setGraphicPen(const QPen & pen, int index) {graphics[index].pen = pen; updateLegend(); if (aupdate) update();}
|
||||
void setGraphicPen(const QPen & pen) {setGraphicPen(pen, curGraphic);}
|
||||
void setGridPen(const QPen & pen) {grid_pen = pen; if (aupdate) update();}
|
||||
void setSelectionPen(const QPen & pen) {selpen = pen;}
|
||||
void setSelectionBrush(const QBrush & brush) {selbrush = brush;}
|
||||
void setNavigationEnabled(bool on) {navigation = on;}
|
||||
void setOpenGL(bool on);
|
||||
void setAntialiasing(bool enabled);
|
||||
void setAutoUpdate(bool enabled) {aupdate = enabled;}
|
||||
void setGridEnabled(bool enabled);
|
||||
void setBorderInputsVisible(bool visible);
|
||||
void setStatusVisible(bool visible);
|
||||
void setLegendVisible(bool visible);
|
||||
void setPaused(bool yes);
|
||||
void setButtons(Graphic::Buttons b);
|
||||
void setButtonsPosition(Graphic::Alignment a);
|
||||
void setHistorySize(double val);
|
||||
void setMaxVisibleTime(double val) {visible_time = val;}
|
||||
void setAutoXIncrement(double val) {inc_x = val;}
|
||||
void setLimit(const QRectF & val) {limit_ = val;}
|
||||
void setMargins(const QRect & val) {margins_ = val; update();}
|
||||
void setMargins(int left_, int right_, int top_, int bottom_) {setMargins(QRect(left_, bottom_, right_, top_));}
|
||||
void setLeftMargin(int value) {margins_.moveLeft(value); setMargins(margins_);}
|
||||
void setRightMargin(int value) {margins_.setWidth(value); setMargins(margins_);}
|
||||
void setTopMargin(int value) {margins_.setHeight(value); setMargins(margins_);}
|
||||
void setBottomMargin(int value) {margins_.moveTop(value); setMargins(margins_);}
|
||||
void setMinimumRepaintInterval(const int & val) {min_repaint_int = val;}
|
||||
void setOnlyExpandY(bool yes);
|
||||
void setOnlyExpandX(bool yes);
|
||||
void setHistogramMinIntervals(int value) {min_int = value; updateGraphics();}
|
||||
void setHistogramMaxIntervals(int value) {max_int = value; updateGraphics();}
|
||||
void setHistogramMinDeltaMultiplier(double value) {mdm = value; updateGraphics();}
|
||||
void setGraphicsData(const GraphicsData & gd);
|
||||
|
||||
void setGridNumbersMultiplierX(double value) {grid_numbers_x = value; updateGraphics();}
|
||||
void setGridNumbersMultiplierY(double value) {grid_numbers_y = value; updateGraphics();}
|
||||
void setGraduationX(Graduation value) {grad_x = value; if (aupdate) update();;}
|
||||
void setGraduationY(Graduation value) {grad_y = value; if (aupdate) update();;}
|
||||
void setGraduationStepX(double sx) {gridx = sx; if (aupdate) update();}
|
||||
void setGraduationStepY(double sy) {gridy = sy; if (aupdate) update();}
|
||||
void setGraduationSteps(double sx, double sy) {gridx = sx; gridy = sy; if (aupdate) update();}
|
||||
void setAxisType(AxisType t) {axis_type_x = t; if (aupdate) update();}
|
||||
|
||||
void addPoint(const QPointF & p, int graphic, bool update_ = true);
|
||||
void addPoint(const QPointF & p, bool update = true) {addPoint(p, curGraphic, update);}
|
||||
void addPoint(double x, double y, int graphic, bool update = true) {addPoint(QPointF(x, y), graphic, update);}
|
||||
void addPoint(double x, double y, bool update = true) {addPoint(QPointF(x, y), update);}
|
||||
void addPoint(double y, int graphic, bool update = true) {addPoint(QPointF(graphics.at(graphic).max_x + inc_x, y), graphic, update);}
|
||||
void addPoint(double y, bool update = true) {addPoint(QPointF(graphics[curGraphic].max_x + inc_x, y), update);}
|
||||
void setGraphicData(const QVector<QPointF> & g, int graphic, bool update_ = true);
|
||||
void setGraphicData(const QVector<QPointF> & g) {setGraphicData(g, curGraphic);}
|
||||
void setGraphicProperties(const QString & name, const QColor & color = Qt::darkRed, Qt::PenStyle style = Qt::SolidLine, double width = 0., bool visible = true) {setGraphicProperties(curGraphic, name, color, style, width, visible);}
|
||||
void setGraphicProperties(int graphic, const QString & name, const QColor & color = Qt::darkRed, Qt::PenStyle style = Qt::SolidLine, double width = 0., bool visible = true);
|
||||
void addGraphic(const QString & name, const QColor & color = Qt::darkRed, Qt::PenStyle style = Qt::SolidLine, double width = 0., bool visible = true);
|
||||
void addGraphic(const GraphicType & gd, bool update = true) {graphics << gd; if (update) updateLegend();}
|
||||
void setVisualRect(const QRectF & rect);
|
||||
void setDefaultRect(const QRectF & rect);
|
||||
void autofit() {on_buttonAutofit_clicked();}
|
||||
void saveImage();
|
||||
void clear();
|
||||
void update(bool force = false);
|
||||
void updateGraphics() {findGraphicsRect(); update();}
|
||||
void setCurrentGraphic(int arg) {if (arg < 0 || arg >= graphics.size()) return; curGraphic = arg;}
|
||||
void setGraphicsCount(int arg, bool update = true);
|
||||
|
||||
void zoom(float factor);
|
||||
void zoomIn() {zoom(1. / 1.2);}
|
||||
void zoomOut() {zoom(1.2);}
|
||||
void fullscreen();
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent * e);
|
||||
virtual void resizeEvent(QResizeEvent * ) {if (leg_update) updateLegend();}
|
||||
virtual QSize sizeHint() const {return QSize(400, 300);}
|
||||
virtual void timerEvent(QTimerEvent * );
|
||||
virtual bool eventFilter(QObject * o, QEvent * e);
|
||||
|
||||
void procGesture(QGesture * g);
|
||||
void setCurrentAction(GraphicAction action);
|
||||
void findGraphicsRect(double start_x = 0., double end_x = 0., double start_y = 0., double end_y = 0.);
|
||||
void tick(int index, bool slide = true, bool update = true);
|
||||
void repaintCanvas(bool force = false) {if (tm.elapsed() < min_repaint_int && !force) return; tm.restart(); canvas->update();}
|
||||
void drawGraphics();
|
||||
void drawGrid();
|
||||
void drawGuides();
|
||||
void drawPause();
|
||||
void drawAction();
|
||||
void updateLegend();
|
||||
void setCanvasCursor(QCursor cursor);
|
||||
void swapToBuffer();
|
||||
void swapToNormal() {bufferActive = false;}
|
||||
void setRectToLines();
|
||||
void checkLines();
|
||||
double splitRange(double range, int count = 1);
|
||||
double splitRangeDate(double range, int count = 1, QString * format = 0, int step[7] = 0);
|
||||
double roundTo(double value, double round_to);
|
||||
void roundDateTime(QDateTime & dt, int c[7]);
|
||||
void addDateTime(QDateTime & dt, int c[7], int mul = 1);
|
||||
QPointF absPoint(QPointF point) {return QPointF(qAbs(point.x()), qAbs(point.y()));}
|
||||
QString pointCoords(QPointF point);
|
||||
QPair<QString, QString> gridMark(double v) const;
|
||||
|
||||
Ui::Graphic * ui;
|
||||
QMutex mutex, mutex_;
|
||||
QWidget * canvas;
|
||||
QImage * buffer;
|
||||
QPainter * painter;
|
||||
QBrush selbrush;
|
||||
QPen grid_pen, selpen;
|
||||
QColor back_color, text_color;
|
||||
QVector<GraphicType> graphics;
|
||||
int curGraphic;
|
||||
GraphicAction curaction, prevaction;
|
||||
QRectF grect, rrect, selrect, limit_, def_rect;
|
||||
QRect margins_;
|
||||
QSize font_sz;
|
||||
QPoint startpos, curpos, prevpos, gridborder;
|
||||
QString label_x, label_y, ppath;
|
||||
Graphic::Buttons buttons_;
|
||||
Graphic::Alignment align;
|
||||
GraphicConf * conf;
|
||||
ELineEdit line_x_min, line_x_max, line_y_min, line_y_max;
|
||||
QTime tm;
|
||||
QIcon icon_exp_x, icon_exp_y, icon_exp_sx, icon_exp_sy;
|
||||
QImage icon_pause_b, icon_pause_f;
|
||||
Graduation grad_x, grad_y;
|
||||
AxisType axis_type_x;
|
||||
double gridx, gridy, history, visible_time, inc_x, mdm, grid_numbers_x, grid_numbers_y, LN2, LN5, LN10;
|
||||
double eminx, eminy, emaxx, emaxy, pause_phase;
|
||||
int legy, lastw, lasth, min_repaint_int, min_int, max_int, timer_pause, thick;
|
||||
bool aalias, aupdate, mupdate, grid, guides, isFit, isEmpty, isOGL, isHover, bufferActive, cancel, pause_, isPrinting;
|
||||
bool hasLblX, hasLblY, navigation, only_expand_y, only_expand_x, is_lines_update, leg_update, visible_update, fullscr;
|
||||
|
||||
protected slots:
|
||||
void canvasPaintEvent(QPaintEvent * );
|
||||
void canvasMouseMoveEvent(QMouseEvent * );
|
||||
void canvasMousePressEvent(QMouseEvent * );
|
||||
void canvasMouseReleaseEvent(QMouseEvent * );
|
||||
void canvasMouseDoubleClickEvent(QMouseEvent * );
|
||||
void canvasWheelEvent(QWheelEvent * );
|
||||
void canvasLeaveEvent(QEvent * );
|
||||
void canvasKeyPressEvent(QKeyEvent * );
|
||||
void graphicVisibleChange(bool checked);
|
||||
void graphicAllVisibleChange(bool checked);
|
||||
void lineXMinChanged(double value) {selrect.setLeft(value); checkLines();}
|
||||
void lineXMaxChanged(double value) {selrect.setRight(value); checkLines();}
|
||||
void lineYMinChanged(double value) {selrect.setBottom(value); checkLines();}
|
||||
void lineYMaxChanged(double value) {selrect.setTop(value); checkLines();}
|
||||
void on_buttonClose_clicked() {emit closeRequest(this);}
|
||||
void on_buttonClear_clicked() {reset(); emit cleared();}
|
||||
void on_buttonAutofit_clicked();
|
||||
void on_buttonConfigure_clicked();
|
||||
void on_buttonFullscreen_clicked() {fullscreen();}
|
||||
void on_buttonSave_clicked() {saveImage();}
|
||||
void on_checkGrid_toggled(bool checked) {grid = checked; update();}
|
||||
void on_checkGuides_toggled(bool checked);
|
||||
void on_checkExpandY_toggled(bool checked);
|
||||
void on_checkExpandX_toggled(bool checked);
|
||||
void on_checkBorderInputs_toggled(bool checked) {setBorderInputsVisible(checked);}
|
||||
void on_checkLegend_toggled(bool checked) {setLegendVisible(checked);}
|
||||
void on_checkPause_toggled(bool checked) {setPaused(checked);}
|
||||
void enterFullscreen();
|
||||
void leaveFullscreen();
|
||||
|
||||
signals:
|
||||
void graphicPaintEvent(QPainter * );
|
||||
void graphicMouseMoveEvent(QPointF point, int buttons);
|
||||
void graphicMousePressEvent(QPointF point, int buttons);
|
||||
void graphicMouseReleaseEvent(QPointF point, int buttons);
|
||||
void graphicWheelEvent(QPointF point, int delta);
|
||||
void closeRequest(QWidget * );
|
||||
void cleared();
|
||||
void visualRectChanged();
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(Graphic::GraphicsData)
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Graphic::Buttons)
|
||||
|
||||
//inline QDataStream & operator <<(QDataStream & s, const Graphic::GraphicsData & v) {s << v; return s;}
|
||||
//inline QDataStream & operator >>(QDataStream & s, Graphic::GraphicsData & v) {s >> v; return s;}
|
||||
|
||||
class __GraphicRegistrator__ {
|
||||
public:
|
||||
__GraphicRegistrator__() {
|
||||
qRegisterMetaType<Graphic::GraphicsData>("Graphic::GraphicsData");
|
||||
qRegisterMetaTypeStreamOperators<Graphic::GraphicsData>("Graphic::GraphicsData");
|
||||
}
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // GRAPHIC_H
|
||||
485
qad/graphic/graphic.ui
Normal file
485
qad/graphic/graphic.ui
Normal file
@@ -0,0 +1,485 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Graphic</class>
|
||||
<widget class="QFrame" name="Graphic">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>564</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QWidget" name="widgetLeft" native="true">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>-10</x>
|
||||
<y>0</y>
|
||||
<width>28</width>
|
||||
<height>361</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layoutButtons">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonAutofit">
|
||||
<property name="toolTip">
|
||||
<string>Autofit</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/zoom-fit-best.png</normaloff>:/icons/zoom-fit-best.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="checkGrid">
|
||||
<property name="toolTip">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/view-grid.png</normaloff>:/icons/view-grid.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="checkGuides">
|
||||
<property name="toolTip">
|
||||
<string>Cursor axis</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/edit-guides.png</normaloff>:/icons/edit-guides.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="checkExpandY">
|
||||
<property name="toolTip">
|
||||
<string>Only expand Y</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/expand_s_y.png</normaloff>:/icons/expand_s_y.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="checkExpandX">
|
||||
<property name="toolTip">
|
||||
<string>Only expand X</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/expand_s_x.png</normaloff>:/icons/expand_s_x.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonFullscreen">
|
||||
<property name="toolTip">
|
||||
<string>Fullscreen</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/view-fullscreen.png</normaloff>:/icons/view-fullscreen.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="checkBorderInputs">
|
||||
<property name="toolTip">
|
||||
<string>Border inputs</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/border-line.png</normaloff>:/icons/border-line.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="checkLegend">
|
||||
<property name="toolTip">
|
||||
<string>Legend</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="checkPause">
|
||||
<property name="toolTip">
|
||||
<string>Pause</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/media-playback-pause.png</normaloff>:/icons/media-playback-pause.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonConfigure">
|
||||
<property name="toolTip">
|
||||
<string>Configure ...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonSave">
|
||||
<property name="toolTip">
|
||||
<string>Save image ...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonClear">
|
||||
<property name="toolTip">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonClose">
|
||||
<property name="toolTip">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/dialog-close.png</normaloff>:/icons/dialog-close.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>79</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="labelCaption">
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="2">
|
||||
<widget class="QWidget" name="widgetRight" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QWidget" name="widgetLX" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2" colspan="2">
|
||||
<layout class="QVBoxLayout" name="layoutCanvas">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="UGLWidget" name="canvas_gl" native="true">
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="UWidget" name="canvas_raster" native="true">
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QWidget" name="widgetLY" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="status">
|
||||
<property name="text">
|
||||
<string>Cursor: ( ; )</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QWidget" name="widgetLegend" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="layoutLegend">
|
||||
<property name="horizontalSpacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>UWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>uwidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>UGLWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>uglwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="qad_graphic.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
103
qad/graphic/graphic_conf.cpp
Normal file
103
qad/graphic/graphic_conf.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#include "graphic_conf.h"
|
||||
#include "ui_graphic_conf.h"
|
||||
|
||||
|
||||
GraphicConf::GraphicConf(QVector<GraphicType> & graphics_, QWidget * parent): QDialog(parent), graphics(graphics_) {
|
||||
ui = new Ui::GraphicConf();
|
||||
ui->setupUi(this);
|
||||
QStringList styles;
|
||||
styles << tr("NoPen") << tr("Solid") << tr("Dash")
|
||||
<< tr("Dot") << tr("Dash-Dot") << tr("Dash-Dot-Dot");
|
||||
ui->comboStyleGrid->setIconSize(QSize(60, 22));
|
||||
ui->comboStyleGraphic->setIconSize(QSize(60, 22));
|
||||
ui->cbGraphicNames->setIconSize(QSize(60, 22));
|
||||
for (int i = 0; i < 6; i++) {
|
||||
QPixmap pix(60, 22);
|
||||
pix.fill();
|
||||
QPainter p(&pix);
|
||||
p.setPen(QPen(Qt::black, 1, (Qt::PenStyle)i));
|
||||
p.drawLine(0, pix.height() / 2, pix.width(), pix.height() / 2);
|
||||
p.end();
|
||||
ui->comboStyleGraphic->addItem(QIcon(pix), styles[i]);
|
||||
ui->comboStyleGrid->addItem(QIcon(pix), styles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::changeEvent(QEvent * e) {
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
return;
|
||||
}
|
||||
QDialog::changeEvent(e);
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::readParams() {
|
||||
ui->cbGraphicNames->clear();
|
||||
for (int i = 0; i < graphicItems.size(); i++)
|
||||
ui->cbGraphicNames->addItem(graphicItems[i].icon, graphicItems[i].name);
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::on_cbGraphicNames_currentIndexChanged(int i) {
|
||||
if (i < 0) return;
|
||||
if (graphicItems.isEmpty()) return;
|
||||
ui->comboStyleGraphic->setCurrentIndex((int)graphics[i].pen.style());
|
||||
ui->colorGraphic->setColor(graphics[i].pen.color());
|
||||
ui->colorFill->setColor(graphics[i].fill_color);
|
||||
ui->spinLineWidthGraphic->setValue(graphics[i].pen.widthF());
|
||||
ui->spinPointWidthGraphic->setValue(graphics[i].pointWidth);
|
||||
ui->checkLines->setChecked(graphics[i].lines);
|
||||
ui->checkPoints->setChecked(graphics[i].points);
|
||||
ui->checkFill->setChecked(graphics[i].fill);
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::on_colorGraphic_colorChanged(const QColor & c) {
|
||||
if (graphicItems.isEmpty()) return;
|
||||
graphics[ui->cbGraphicNames->currentIndex()].pen.setColor(c);
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::on_comboStyleGraphic_currentIndexChanged(int index) {
|
||||
if (graphicItems.isEmpty()) return;
|
||||
graphics[ui->cbGraphicNames->currentIndex()].pen.setStyle((Qt::PenStyle)index);
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::on_spinLineWidthGraphic_valueChanged(double value) {
|
||||
if (graphicItems.isEmpty()) return;
|
||||
if (qRound(value) == value) graphics[ui->cbGraphicNames->currentIndex()].pen.setWidth(qRound(value));
|
||||
else graphics[ui->cbGraphicNames->currentIndex()].pen.setWidthF(value);
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::on_spinPointWidthGraphic_valueChanged(double value) {
|
||||
if (graphicItems.isEmpty()) return;
|
||||
graphics[ui->cbGraphicNames->currentIndex()].pointWidth = value;
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::on_checkLines_toggled(bool on) {
|
||||
if (graphicItems.isEmpty()) return;
|
||||
graphics[ui->cbGraphicNames->currentIndex()].lines = on;
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::on_checkPoints_toggled(bool on) {
|
||||
if (graphicItems.isEmpty()) return;
|
||||
graphics[ui->cbGraphicNames->currentIndex()].points = on;
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::on_checkFill_toggled(bool on) {
|
||||
if (graphicItems.isEmpty()) return;
|
||||
graphics[ui->cbGraphicNames->currentIndex()].fill = on;
|
||||
}
|
||||
|
||||
|
||||
void GraphicConf::on_colorFill_colorChanged(const QColor & color) {
|
||||
if (graphicItems.isEmpty()) return;
|
||||
graphics[ui->cbGraphicNames->currentIndex()].fill_color = color;
|
||||
}
|
||||
90
qad/graphic/graphic_conf.h
Normal file
90
qad/graphic/graphic_conf.h
Normal file
@@ -0,0 +1,90 @@
|
||||
#ifndef GRAPHIC_CONF_H
|
||||
#define GRAPHIC_CONF_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QCheckBox>
|
||||
#include <QPen>
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class GraphicConf;
|
||||
};
|
||||
|
||||
|
||||
struct GraphicType {
|
||||
GraphicType(QString name_ = "y(x)", QColor color = Qt::red, Qt::PenStyle style = Qt::SolidLine, double width = 0., bool visible_ = true) {
|
||||
pen.setColor(color);
|
||||
pen.setStyle(style);
|
||||
lines = true;
|
||||
points = false;
|
||||
fill = false;
|
||||
fill_color = Qt::yellow;
|
||||
if (qRound(width) == width) pen.setWidth(qRound(width));
|
||||
else pen.setWidthF(width);
|
||||
pen.setWidth(1);
|
||||
pen.setCosmetic(true);
|
||||
max_x = 0.;
|
||||
name = name_;
|
||||
visible = visible_;
|
||||
pointWidth = 2.;
|
||||
pb = new QCheckBox(name);
|
||||
}
|
||||
//~GraphicType() {delete pb;}
|
||||
QString name;
|
||||
QPolygonF polyline;
|
||||
QPolygonF polyline_pause;
|
||||
QPen pen;
|
||||
QColor fill_color;
|
||||
bool lines;
|
||||
bool points;
|
||||
bool fill;
|
||||
double pointWidth;
|
||||
double max_x;
|
||||
double max_x_pause;
|
||||
QCheckBox * pb;
|
||||
QIcon icon;
|
||||
bool visible;
|
||||
};
|
||||
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const GraphicType & v) {s << v.name << v.pen << v.fill_color << v.lines << v.points << v.fill << v.pointWidth << v.visible; return s;}
|
||||
inline QDataStream & operator >>(QDataStream & s, GraphicType & v) {s >> v.name >> v.pen >> v.fill_color >> v.lines >> v.points >> v.fill >> v.pointWidth >> v.visible; return s;}
|
||||
|
||||
|
||||
class GraphicConf: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class Graphic;
|
||||
public:
|
||||
explicit GraphicConf(QVector<GraphicType> & graphics_, QWidget * parent = 0);
|
||||
|
||||
struct GraphicItem {
|
||||
QString name;
|
||||
QIcon icon;
|
||||
};
|
||||
|
||||
void readParams();
|
||||
|
||||
QVector<GraphicType> & graphics;
|
||||
QVector<GraphicItem> graphicItems;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent * e);
|
||||
|
||||
Ui::GraphicConf * ui;
|
||||
|
||||
private slots:
|
||||
void on_cbGraphicNames_currentIndexChanged(int index);
|
||||
void on_colorGraphic_colorChanged(const QColor &);
|
||||
void on_colorFill_colorChanged(const QColor &);
|
||||
void on_comboStyleGraphic_currentIndexChanged(int index);
|
||||
void on_spinLineWidthGraphic_valueChanged(double value);
|
||||
void on_spinPointWidthGraphic_valueChanged(double value);
|
||||
void on_checkLines_toggled(bool on);
|
||||
void on_checkPoints_toggled(bool on);
|
||||
void on_checkFill_toggled(bool on);
|
||||
|
||||
};
|
||||
|
||||
#endif // GRAPHIC_CONF_H
|
||||
678
qad/graphic/graphic_conf.ui
Normal file
678
qad/graphic/graphic_conf.ui
Normal file
@@ -0,0 +1,678 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GraphicConf</class>
|
||||
<widget class="QDialog" name="GraphicConf">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>448</width>
|
||||
<height>513</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Graphic parameters</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Appearance</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkInputs">
|
||||
<property name="text">
|
||||
<string>Border inputs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkAAlias">
|
||||
<property name="text">
|
||||
<string>Antialiasing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkStatus">
|
||||
<property name="text">
|
||||
<string>Status bar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="checkOGL">
|
||||
<property name="text">
|
||||
<string>OpenGL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="checkLegend">
|
||||
<property name="text">
|
||||
<string>Legend</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Background color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="ColorButton" name="colorBackground">
|
||||
<property name="useAlphaChannel">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Text color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="ColorButton" name="colorText">
|
||||
<property name="useAlphaChannel">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_1">
|
||||
<property name="title">
|
||||
<string>Graphics</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QComboBox" name="cbGraphicNames">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="ColorButton" name="colorGraphic">
|
||||
<property name="useAlphaChannel">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Style:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboStyleGraphic"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="checkLines">
|
||||
<property name="text">
|
||||
<string>Lines width:</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinLineWidthGraphic">
|
||||
<property name="decimals">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="checkPoints">
|
||||
<property name="text">
|
||||
<string>Points width:</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinPointWidthGraphic">
|
||||
<property name="decimals">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="checkFill">
|
||||
<property name="text">
|
||||
<string>Fill:</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="ColorButton" name="colorFill">
|
||||
<property name="useAlphaChannel">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="ColorButton" name="colorGrid">
|
||||
<property name="useAlphaChannel">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Style:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboStyleGrid"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinWidthGrid">
|
||||
<property name="decimals">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinGridStepX">
|
||||
<property name="decimals">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.001000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Step X:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Step Y:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinGridStepY">
|
||||
<property name="decimals">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.001000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>30.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkGridAutoX">
|
||||
<property name="text">
|
||||
<string>Auto X</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkGridAutoY">
|
||||
<property name="text">
|
||||
<string>Auto Y</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Margins</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="1" column="5">
|
||||
<widget class="QSpinBox" name="spinMarginR">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QSpinBox" name="spinMarginB">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="labelAll">
|
||||
<property name="text">
|
||||
<string>All:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinMarginL">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Right:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Left:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Bottom:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSpinBox" name="spinMarginT">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Top:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QSpinBox" name="spinMarginT_2">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>colorbutton.h</header>
|
||||
<slots>
|
||||
<signal>colorChanged(QColor)</signal>
|
||||
</slots>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>checkAAlias</tabstop>
|
||||
<tabstop>checkOGL</tabstop>
|
||||
<tabstop>colorBackground</tabstop>
|
||||
<tabstop>colorText</tabstop>
|
||||
<tabstop>colorGrid</tabstop>
|
||||
<tabstop>comboStyleGrid</tabstop>
|
||||
<tabstop>spinWidthGrid</tabstop>
|
||||
<tabstop>cbGraphicNames</tabstop>
|
||||
<tabstop>colorGraphic</tabstop>
|
||||
<tabstop>comboStyleGraphic</tabstop>
|
||||
<tabstop>checkLines</tabstop>
|
||||
<tabstop>spinLineWidthGraphic</tabstop>
|
||||
<tabstop>checkPoints</tabstop>
|
||||
<tabstop>spinPointWidthGraphic</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>GraphicConf</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>255</x>
|
||||
<y>641</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>245</x>
|
||||
<y>207</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkLines</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinLineWidthGraphic</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>322</x>
|
||||
<y>410</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>415</x>
|
||||
<y>411</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkPoints</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinPointWidthGraphic</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>322</x>
|
||||
<y>434</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>415</x>
|
||||
<y>435</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>GraphicConf</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>294</x>
|
||||
<y>641</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>288</x>
|
||||
<y>268</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkFill</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>colorFill</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>322</x>
|
||||
<y>458</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>415</x>
|
||||
<y>460</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinMarginT_2</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>spinMarginT</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>259</x>
|
||||
<y>221</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>249</x>
|
||||
<y>191</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinMarginT_2</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>spinMarginR</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>268</x>
|
||||
<y>220</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>371</x>
|
||||
<y>220</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinMarginT_2</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>spinMarginB</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>233</x>
|
||||
<y>230</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>234</x>
|
||||
<y>252</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>spinMarginT_2</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>spinMarginL</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>213</x>
|
||||
<y>230</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>133</x>
|
||||
<y>229</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
BIN
qad/graphic/lang/qad_graphic_ru.qm
Normal file
BIN
qad/graphic/lang/qad_graphic_ru.qm
Normal file
Binary file not shown.
351
qad/graphic/lang/qad_graphic_ru.ts
Normal file
351
qad/graphic/lang/qad_graphic_ru.ts
Normal file
@@ -0,0 +1,351 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="ru_RU">
|
||||
<context>
|
||||
<name>Graphic</name>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="44"/>
|
||||
<location filename="../ui_graphic.h" line="320"/>
|
||||
<source>Autofit</source>
|
||||
<translation>Автомасштаб</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="61"/>
|
||||
<location filename="../ui_graphic.h" line="323"/>
|
||||
<source>Grid</source>
|
||||
<translation>Сетка</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="84"/>
|
||||
<location filename="../ui_graphic.h" line="326"/>
|
||||
<source>Cursor axis</source>
|
||||
<translation>Плавающие оси</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="104"/>
|
||||
<location filename="../ui_graphic.h" line="329"/>
|
||||
<source>Only expand Y</source>
|
||||
<translation>Только расширять Y</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="124"/>
|
||||
<location filename="../ui_graphic.h" line="332"/>
|
||||
<source>Only expand X</source>
|
||||
<translation>Только расширять X</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="144"/>
|
||||
<location filename="../ui_graphic.h" line="335"/>
|
||||
<source>Fullscreen</source>
|
||||
<translation>Во весь экран</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="161"/>
|
||||
<location filename="../ui_graphic.h" line="338"/>
|
||||
<source>Border inputs</source>
|
||||
<translation>Граничные поля ввода</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="184"/>
|
||||
<location filename="../ui_graphic.h" line="341"/>
|
||||
<source>Legend</source>
|
||||
<translation>Легенда</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="207"/>
|
||||
<location filename="../ui_graphic.h" line="344"/>
|
||||
<source>Configure ...</source>
|
||||
<translation>Настроить ...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="224"/>
|
||||
<location filename="../ui_graphic.h" line="347"/>
|
||||
<source>Save image ...</source>
|
||||
<translation>Сохранить изображение ...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="257"/>
|
||||
<location filename="../ui_graphic.h" line="350"/>
|
||||
<source>Clear</source>
|
||||
<translation>Очистить</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="274"/>
|
||||
<location filename="../ui_graphic.h" line="353"/>
|
||||
<source>Close</source>
|
||||
<translation>Закрыть</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="425"/>
|
||||
<location filename="../ui_graphic.h" line="355"/>
|
||||
<source>Cursor: ( ; )</source>
|
||||
<translation>Курсор: ( ; )</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="205"/>
|
||||
<location filename="../graphic.cpp" line="809"/>
|
||||
<source>Cursor: </source>
|
||||
<translation>Курсор: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="216"/>
|
||||
<source>Selection</source>
|
||||
<translation>Выделение</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="217"/>
|
||||
<source>Size</source>
|
||||
<translation>Размер</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="221"/>
|
||||
<location filename="../graphic.cpp" line="227"/>
|
||||
<source>Range</source>
|
||||
<translation>Диапазон</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="222"/>
|
||||
<location filename="../graphic.cpp" line="228"/>
|
||||
<source>Length</source>
|
||||
<translation>Длина</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="329"/>
|
||||
<location filename="../graphic.cpp" line="380"/>
|
||||
<source>Cursor</source>
|
||||
<translation>Курсор</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="531"/>
|
||||
<source>Save Image</source>
|
||||
<translation>Сохранить изображение</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="576"/>
|
||||
<source>y(x)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="1124"/>
|
||||
<source>Check all</source>
|
||||
<translation>Выбрать все</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GraphicConf</name>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="17"/>
|
||||
<location filename="../ui_graphic_conf.h" line="450"/>
|
||||
<source>Graphic parameters</source>
|
||||
<translation>Параметры графика</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="32"/>
|
||||
<location filename="../ui_graphic_conf.h" line="451"/>
|
||||
<source>Appearance</source>
|
||||
<translation>Внешний вид</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="46"/>
|
||||
<location filename="../ui_graphic_conf.h" line="452"/>
|
||||
<source>Border inputs</source>
|
||||
<translation>Граничные поля ввода</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="53"/>
|
||||
<location filename="../ui_graphic_conf.h" line="453"/>
|
||||
<source>Antialiasing</source>
|
||||
<translation>Сглаживание</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="60"/>
|
||||
<location filename="../ui_graphic_conf.h" line="454"/>
|
||||
<source>Status bar</source>
|
||||
<translation>Панель статуса</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="67"/>
|
||||
<location filename="../ui_graphic_conf.h" line="455"/>
|
||||
<source>OpenGL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="74"/>
|
||||
<location filename="../ui_graphic_conf.h" line="456"/>
|
||||
<source>Legend</source>
|
||||
<translation>Легенда</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="94"/>
|
||||
<location filename="../ui_graphic_conf.h" line="457"/>
|
||||
<source>Background color:</source>
|
||||
<translation>Цвет фона:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="114"/>
|
||||
<location filename="../ui_graphic_conf.h" line="458"/>
|
||||
<source>Text color:</source>
|
||||
<translation>Цвет текста:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="133"/>
|
||||
<location filename="../ui_graphic_conf.h" line="459"/>
|
||||
<source>Graphics</source>
|
||||
<translation>Графики</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="161"/>
|
||||
<location filename="../graphic_conf.ui" line="263"/>
|
||||
<location filename="../ui_graphic_conf.h" line="460"/>
|
||||
<location filename="../ui_graphic_conf.h" line="466"/>
|
||||
<source>Color:</source>
|
||||
<translation>Цвет:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="175"/>
|
||||
<location filename="../graphic_conf.ui" line="277"/>
|
||||
<location filename="../ui_graphic_conf.h" line="461"/>
|
||||
<location filename="../ui_graphic_conf.h" line="467"/>
|
||||
<source>Style:</source>
|
||||
<translation>Стиль:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="185"/>
|
||||
<location filename="../ui_graphic_conf.h" line="462"/>
|
||||
<source>Lines width:</source>
|
||||
<translation>Толщина линий:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="205"/>
|
||||
<location filename="../ui_graphic_conf.h" line="463"/>
|
||||
<source>Points width:</source>
|
||||
<translation>Толщина точек:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="225"/>
|
||||
<location filename="../ui_graphic_conf.h" line="464"/>
|
||||
<source>Fill:</source>
|
||||
<translation>Заливка:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="245"/>
|
||||
<location filename="../ui_graphic_conf.h" line="465"/>
|
||||
<source>Grid</source>
|
||||
<translation>Сетка</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="287"/>
|
||||
<location filename="../ui_graphic_conf.h" line="468"/>
|
||||
<source>Width:</source>
|
||||
<translation>Толщина:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="317"/>
|
||||
<location filename="../ui_graphic_conf.h" line="469"/>
|
||||
<source>Step X:</source>
|
||||
<translation>Шаг X:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="324"/>
|
||||
<location filename="../ui_graphic_conf.h" line="470"/>
|
||||
<source>Step Y:</source>
|
||||
<translation>Шаг Y:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="347"/>
|
||||
<location filename="../ui_graphic_conf.h" line="471"/>
|
||||
<source>Auto X</source>
|
||||
<translation>Авто X</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="357"/>
|
||||
<location filename="../ui_graphic_conf.h" line="472"/>
|
||||
<source>Auto Y</source>
|
||||
<translation>Авто Y</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Auto step</source>
|
||||
<translation type="obsolete">Автоматический шаг</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="390"/>
|
||||
<location filename="../ui_graphic_conf.h" line="473"/>
|
||||
<source>Margins</source>
|
||||
<translation>Поля</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="402"/>
|
||||
<location filename="../graphic_conf.ui" line="412"/>
|
||||
<location filename="../graphic_conf.ui" line="432"/>
|
||||
<location filename="../graphic_conf.ui" line="472"/>
|
||||
<location filename="../graphic_conf.ui" line="492"/>
|
||||
<location filename="../ui_graphic_conf.h" line="474"/>
|
||||
<location filename="../ui_graphic_conf.h" line="475"/>
|
||||
<location filename="../ui_graphic_conf.h" line="477"/>
|
||||
<location filename="../ui_graphic_conf.h" line="481"/>
|
||||
<location filename="../ui_graphic_conf.h" line="483"/>
|
||||
<source> px</source>
|
||||
<translation> пикс</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="422"/>
|
||||
<location filename="../ui_graphic_conf.h" line="476"/>
|
||||
<source>All:</source>
|
||||
<translation>Все:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="442"/>
|
||||
<location filename="../ui_graphic_conf.h" line="478"/>
|
||||
<source>Right:</source>
|
||||
<translation>Правое:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="452"/>
|
||||
<location filename="../ui_graphic_conf.h" line="479"/>
|
||||
<source>Left:</source>
|
||||
<translation>Левое:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="462"/>
|
||||
<location filename="../ui_graphic_conf.h" line="480"/>
|
||||
<source>Bottom:</source>
|
||||
<translation>Нижнее:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="482"/>
|
||||
<location filename="../ui_graphic_conf.h" line="482"/>
|
||||
<source>Top:</source>
|
||||
<translation>Верхнее:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="7"/>
|
||||
<source>NoPen</source>
|
||||
<translation>НетЛинии</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="7"/>
|
||||
<source>Solid</source>
|
||||
<translation>Сплошная</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="7"/>
|
||||
<source>Dash</source>
|
||||
<translation>Штриховая</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="8"/>
|
||||
<source>Dot</source>
|
||||
<translation>Пунктирная</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="8"/>
|
||||
<source>Dash-Dot</source>
|
||||
<translation>ШтрихПунктирная</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="8"/>
|
||||
<source>Dash-Dot-Dot</source>
|
||||
<translation>ШтрихПунктирПунктирная</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
1
qad/graphic/plugin/CMakeLists.txt
Normal file
1
qad/graphic/plugin/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
qad_plugin(graphic "")
|
||||
69
qad/graphic/plugin/graphicplugin.cpp
Normal file
69
qad/graphic/plugin/graphicplugin.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "graphic.h"
|
||||
#include "graphicplugin.h"
|
||||
#include <QtCore/QtPlugin>
|
||||
|
||||
|
||||
GraphicPlugin::GraphicPlugin(QObject * parent): QObject(parent) {
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
|
||||
void GraphicPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
|
||||
if (m_initialized)
|
||||
return;
|
||||
|
||||
// Add extension registrations, etc. here
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
bool GraphicPlugin::isInitialized() const {
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
|
||||
QWidget * GraphicPlugin::createWidget(QWidget * parent) {
|
||||
return new Graphic(parent);
|
||||
}
|
||||
|
||||
|
||||
QString GraphicPlugin::name() const {
|
||||
return QLatin1String("Graphic");
|
||||
}
|
||||
|
||||
|
||||
QString GraphicPlugin::group() const {
|
||||
return QLatin1String("Display Widgets");
|
||||
}
|
||||
|
||||
|
||||
QIcon GraphicPlugin::icon() const {
|
||||
return QIcon(":/icons/graphic.png");
|
||||
}
|
||||
|
||||
|
||||
QString GraphicPlugin::toolTip() const {
|
||||
return QLatin1String("");//QLatin1String("Widget for display any math graphics with grid and navigation");
|
||||
}
|
||||
|
||||
|
||||
QString GraphicPlugin::whatsThis() const {
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
bool GraphicPlugin::isContainer() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicPlugin::domXml() const {
|
||||
return QLatin1String("<widget class=\"Graphic\" name=\"graphic\">\n</widget>\n");
|
||||
}
|
||||
|
||||
|
||||
QString GraphicPlugin::includeFile() const {
|
||||
return QLatin1String("graphic.h");
|
||||
}
|
||||
|
||||
31
qad/graphic/plugin/graphicplugin.h
Normal file
31
qad/graphic/plugin/graphicplugin.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef GRAPHICPLUGIN_H
|
||||
#define GRAPHICPLUGIN_H
|
||||
|
||||
#include <QDesignerCustomWidgetInterface>
|
||||
|
||||
class GraphicPlugin: public QObject, public QDesignerCustomWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QDesignerCustomWidgetInterface)
|
||||
|
||||
public:
|
||||
GraphicPlugin(QObject * parent = 0);
|
||||
|
||||
bool isContainer() const;
|
||||
bool isInitialized() const;
|
||||
QIcon icon() const;
|
||||
QString domXml() const;
|
||||
QString group() const;
|
||||
QString includeFile() const;
|
||||
QString name() const;
|
||||
QString toolTip() const;
|
||||
QString whatsThis() const;
|
||||
QWidget * createWidget(QWidget * parent);
|
||||
void initialize(QDesignerFormEditorInterface * core);
|
||||
|
||||
private:
|
||||
bool m_initialized;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
14
qad/graphic/plugin/qad_graphic.cpp
Normal file
14
qad/graphic/plugin/qad_graphic.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "graphicplugin.h"
|
||||
#include "qad_graphic.h"
|
||||
|
||||
QADGraphic::QADGraphic(QObject * parent): QObject(parent)
|
||||
{
|
||||
m_widgets.append(new GraphicPlugin(this));
|
||||
}
|
||||
|
||||
|
||||
QList<QDesignerCustomWidgetInterface * > QADGraphic::customWidgets() const {
|
||||
return m_widgets;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(qad_graphic_plugin, QADGraphic)
|
||||
21
qad/graphic/plugin/qad_graphic.h
Normal file
21
qad/graphic/plugin/qad_graphic.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef QAD_GRAPHIC_H
|
||||
#define QAD_GRAPHIC_H
|
||||
|
||||
#include <QtDesigner/QtDesigner>
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
class QADGraphic: public QObject, public QDesignerCustomWidgetCollectionInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
|
||||
|
||||
public:
|
||||
explicit QADGraphic(QObject * parent = 0);
|
||||
virtual QList<QDesignerCustomWidgetInterface * > customWidgets() const;
|
||||
|
||||
private:
|
||||
QList<QDesignerCustomWidgetInterface * > m_widgets;
|
||||
|
||||
};
|
||||
|
||||
#endif // QAD_GRAPHIC_H
|
||||
32
qad/graphic/qad_graphic.qrc
Normal file
32
qad/graphic/qad_graphic.qrc
Normal file
@@ -0,0 +1,32 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>lang/qad_graphic_ru.qm</file>
|
||||
<file>../icons/media-playback-pause.png</file>
|
||||
<file>../icons/dialog-close.png</file>
|
||||
<file>../icons/edit-clear.png</file>
|
||||
<file>../icons/edit-guides.png</file>
|
||||
<file>../icons/view-grid.png</file>
|
||||
<file>../icons/zoom-fit-best.png</file>
|
||||
<file>../icons/configure.png</file>
|
||||
<file>../icons/document-save.png</file>
|
||||
<file>../icons/edit-clear-locationbar-rtl.png</file>
|
||||
<file>../icons/edit-find.png</file>
|
||||
<file>../icons/list-add.png</file>
|
||||
<file>../icons/edit-delete.png</file>
|
||||
<file>../icons/item.png</file>
|
||||
<file>../icons/node-add.png</file>
|
||||
<file>../icons/node.png</file>
|
||||
<file>../icons/edit-copy.png</file>
|
||||
<file>../icons/edit-paste.png</file>
|
||||
<file>../icons/expand_s_x.png</file>
|
||||
<file>../icons/expand_s_y.png</file>
|
||||
<file>../icons/expand_x.png</file>
|
||||
<file>../icons/expand_y.png</file>
|
||||
<file>../icons/border-line.png</file>
|
||||
<file>../icons/legend.png</file>
|
||||
<file>../icons/graphic.png</file>
|
||||
<file>../icons/view-fullscreen.png</file>
|
||||
<file>../icons/pause-back.png</file>
|
||||
<file>../icons/pause-front.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
48
qad/graphic/uglwidget.h
Normal file
48
qad/graphic/uglwidget.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef UGLWIDGET_H
|
||||
#define UGLWIDGET_H
|
||||
|
||||
#include <QGLWidget>
|
||||
#ifndef GL_MULTISAMPLE
|
||||
#define GL_MULTISAMPLE 0x809D
|
||||
#endif
|
||||
|
||||
|
||||
class UGLWidget: public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UGLWidget(QWidget * parent = 0): QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::AlphaChannel | QGL::DirectRendering | QGL::SampleBuffers), parent) {};
|
||||
UGLWidget(QGLContext * context, QWidget * parent = 0): QGLWidget(context, parent) {};
|
||||
|
||||
signals:
|
||||
void closeEvent(QCloseEvent * e);
|
||||
void dragEnterEvent(QDragEnterEvent * e);
|
||||
void dragLeaveEvent(QDragLeaveEvent * e);
|
||||
void dragMoveEvent(QDragMoveEvent * e);
|
||||
void dropEvent(QDropEvent * e);
|
||||
void enterEvent(QEvent * e);
|
||||
void hideEvent(QHideEvent * e);
|
||||
void keyPressEvent(QKeyEvent * e);
|
||||
void keyReleaseEvent(QKeyEvent * e);
|
||||
void leaveEvent(QEvent * e);
|
||||
void mouseDoubleClickEvent(QMouseEvent * e);
|
||||
void mouseMoveEvent(QMouseEvent * e);
|
||||
void mousePressEvent(QMouseEvent * e);
|
||||
void mouseReleaseEvent(QMouseEvent * e);
|
||||
void moveEvent(QMoveEvent * e);
|
||||
void resizeEvent(QResizeEvent * e);
|
||||
void showEvent(QShowEvent * e);
|
||||
void wheelEvent(QWheelEvent * e);
|
||||
void paintEvent(QPaintEvent * e);
|
||||
void glDraw();
|
||||
void glInit();
|
||||
void initializeGL();
|
||||
void initializeOverlayGL();
|
||||
void paintGL();
|
||||
void paintOverlayGL();
|
||||
void resizeGL(int width, int height);
|
||||
void resizeOverlayGL(int width, int height);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
52
qad/graphic/uwidget.h
Normal file
52
qad/graphic/uwidget.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef UWIDGET_H
|
||||
#define UWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
#include <QStyleOption>
|
||||
#include <QEvent>
|
||||
|
||||
|
||||
class UWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UWidget(QWidget * parent = 0): QWidget(parent) {};
|
||||
|
||||
private:
|
||||
virtual bool event(QEvent * e) {
|
||||
if (e->type() != QEvent::Paint) return QWidget::event(e);
|
||||
e->accept();
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
emit paintEvent((QPaintEvent * )e);
|
||||
return true;
|
||||
}
|
||||
|
||||
signals:
|
||||
void closeEvent(QCloseEvent * e);
|
||||
void dragEnterEvent(QDragEnterEvent * e);
|
||||
void dragLeaveEvent(QDragLeaveEvent * e);
|
||||
void dragMoveEvent(QDragMoveEvent * e);
|
||||
void dropEvent(QDropEvent * e);
|
||||
void enterEvent(QEvent * e);
|
||||
void hideEvent(QHideEvent * e);
|
||||
void keyPressEvent(QKeyEvent * e);
|
||||
void keyReleaseEvent(QKeyEvent * e);
|
||||
void leaveEvent(QEvent * e);
|
||||
void mouseDoubleClickEvent(QMouseEvent * e);
|
||||
void mouseMoveEvent(QMouseEvent * e);
|
||||
void mousePressEvent(QMouseEvent * e);
|
||||
void mouseReleaseEvent(QMouseEvent * e);
|
||||
void moveEvent(QMoveEvent * e);
|
||||
void resizeEvent(QResizeEvent * e);
|
||||
void showEvent(QShowEvent * e);
|
||||
void wheelEvent(QWheelEvent * e);
|
||||
void paintEvent(QPaintEvent * e);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user