graphic refactoring

graphic buttons
menu for save and export
enable grid in config and save it in session
remove traceX traceY
This commit is contained in:
2023-01-22 15:27:49 +03:00
parent c166c040b0
commit 56246e657a
8 changed files with 798 additions and 546 deletions

View File

@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
project(QAD)
set(QAD_MAJOR 2)
set(QAD_MINOR 13)
set(QAD_MINOR 14)
set(QAD_REVISION 0)
set(QAD_SUFFIX )
set(QAD_COMPANY SHS)

View File

@@ -90,6 +90,7 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
func_gridMarkX = func_gridMarkY = nullptr;
ui = new Ui::Graphic();
ui->setupUi(this);
ui->status->hide();
ui->scrollLegend->layout()->addWidget(new LegendScrollArea(ui->widgetLegend));
ui->scrollLegend->hide();
fillDateFormats();
@@ -122,20 +123,16 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
QActionGroup * agroup = new QActionGroup(this);
agroup->addAction(ui->graphic_actionGuidesFree);
agroup->addAction(ui->graphic_actionGuidesTrace);
agroup->addAction(ui->graphic_actionGuidesTraceX);
agroup->addAction(ui->graphic_actionGuidesTraceY);
ui->graphic_actionGuidesFree->setProperty("_value", (int)Free);
ui->graphic_actionGuidesTrace->setProperty("_value", (int)TraceXY);
ui->graphic_actionGuidesTraceX->setProperty("_value", (int)TraceX);
ui->graphic_actionGuidesTraceY->setProperty("_value", (int)TraceY);
ui->graphic_actionGuidesTrace->setProperty("_value", (int)Trace);
ui->graphic_actionGuidesFree->setChecked(true);
connect(agroup, SIGNAL(triggered(QAction *)), this, SLOT(actionGuidesTriggered(QAction *)));
ui->graphic_checkGuides->addAction(ui->graphic_actionGuidesFree);
ui->graphic_checkGuides->addAction(ui->graphic_actionGuidesTrace);
ui->graphic_checkGuides->addAction(ui->graphic_actionGuidesTraceX);
ui->graphic_checkGuides->addAction(ui->graphic_actionGuidesTraceY);
ui->graphic_buttonAutofit->addAction(ui->graphic_actionExpandX);
ui->graphic_buttonAutofit->addAction(ui->graphic_actionExpandY);
ui->graphic_buttonSaveMenu->addAction(ui->graphic_actionSaveImage);
ui->graphic_buttonSaveMenu->addAction(ui->graphic_actionExportCSV);
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);
@@ -169,8 +166,8 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
emaxx = emaxy = DBL_MIN;
grad_x = grad_y = Auto;
axis_type_x = Numeric;
floating_axis_type = Free;
min_repaint_int = 25;
floating_axis_type = Trace;
min_repaint_int = 25; // 40 Hz repaint interval
lastw = lasth = 0;
inc_x = 1.;
// buffer = 0;
@@ -191,8 +188,8 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
text_color = palette().color(QPalette::WindowText);
grid_pen = QPen(palette().color(QPalette::Disabled, QPalette::WindowText), 0., Qt::DotLine);
graphics.append(GraphicType());
curGraphic = curTrace = 0;
selpen = palette().color(QPalette::WindowText);
curGraphic = 0;
selpen = palette().color(QPalette::WindowText);
selpen.setStyle(Qt::DashLine);
back_color = palette().color(QPalette::Base);
buttons_ = AllButtons;
@@ -206,7 +203,7 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
updateLegend();
setRectToLines();
conf = new GraphicConf(graphics, this);
connect(conf, SIGNAL(exportClicked()), this, SLOT(on_graphic_buttonExport_clicked()));
connect(conf, SIGNAL(exportClicked()), this, SLOT(on_graphic_actionExportCSV_triggered()));
}
@@ -258,7 +255,7 @@ void Graphic::timerEvent(QTimerEvent * e) {
if (e->timerId() == timer_pause) {
pause_phase += 0.02;
if (pause_phase > 1.) pause_phase -= 1.;
update();
repaintCanvas();
}
if (e->timerId() == timer_record) {
QPixmap im(canvas->size());
@@ -384,7 +381,7 @@ void Graphic::procZoom(QPointF view_center, double dzoom, Qt::KeyboardModifiers
void Graphic::totalUpdate() {
isFit = false;
emit visualRectChanged();
update(true);
repaintCanvas(true);
setRectToLines();
}
@@ -479,11 +476,10 @@ void Graphic::canvasMouseMoveEvent(QMouseEvent * e) {
curpos = e->pos();
curpos_r = canvas2real(curpos);
QPointF dp;
QString cursorstr = tr("Cursor: ") + pointCoords(curpos_r);
emit graphicMouseMoveEvent(curpos_r, e->buttons());
if (e->buttons() == Qt::NoButton) {
ui->status->setText(cursorstr);
if (guides) update();
if (ui->status->isVisible()) ui->status->setText(tr("Cursor: ") + pointCoords(curpos_r));
if (guides) repaintCanvas();
return;
}
if (!navigation) return;
@@ -494,18 +490,26 @@ void Graphic::canvasMouseMoveEvent(QMouseEvent * e) {
return;
switch (curaction) {
case gaZoomInRect:
ui->status->setText(tr("Selection") + ": " + pointCoords(startpos_r) + " -> " + pointCoords(curpos_r) + ", " + tr("Size") + ": " +
pointCoords(absPoint(curpos_r - startpos_r)));
if (ui->status->isVisible()) {
ui->status->setText(tr("Selection") + ": " + pointCoords(startpos_r) + " -> " + pointCoords(curpos_r) + ", " + tr("Size") +
": " + pointCoords(absPoint(curpos_r - startpos_r)));
}
repaintCanvas(true);
break;
case gaZoomRangeX:
ui->status->setText(tr("Range") + ": " + QString::number(startpos_r.x(), 'f', 3) + " -> " + QString::number(curpos_r.x(), 'f', 3) +
", " + tr("Length") + ": " + QString::number(qAbs(curpos_r.x() - startpos_r.x()), 'f', 3));
if (ui->status->isVisible()) {
ui->status->setText(tr("Range") + ": " + QString::number(startpos_r.x(), 'f', 3) + " -> " +
QString::number(curpos_r.x(), 'f', 3) + ", " + tr("Length") + ": " +
QString::number(qAbs(curpos_r.x() - startpos_r.x()), 'f', 3));
}
repaintCanvas(true);
break;
case gaZoomRangeY:
ui->status->setText(tr("Range") + ": " + QString::number(startpos_r.y(), 'f', 3) + " -> " + QString::number(curpos_r.y(), 'f', 3) +
", " + tr("Length") + ": " + QString::number(qAbs(curpos_r.y() - startpos_r.y()), 'f', 3));
if (ui->status->isVisible()) {
ui->status->setText(tr("Range") + ": " + QString::number(startpos_r.y(), 'f', 3) + " -> " +
QString::number(curpos_r.y(), 'f', 3) + ", " + tr("Length") + ": " +
QString::number(qAbs(curpos_r.y() - startpos_r.y()), 'f', 3));
}
repaintCanvas(true);
break;
case gaMove:
@@ -605,10 +609,11 @@ void Graphic::canvasMouseReleaseEvent(QMouseEvent * e) {
}
}
swapToNormal();
update(true);
repaintCanvas(true);
}
if (ui->status->isVisible()) {
ui->status->setText(tr("Cursor") + ": " + pointCoords(canvas2real(QPointF(e->pos()))));
}
QPointF rp = canvas2real(QPointF(e->pos()));
ui->status->setText(tr("Cursor") + ": " + pointCoords(rp));
emit visualRectChanged();
}
@@ -647,7 +652,7 @@ void Graphic::zoom(float factor) {
selrect.width() * factor,
selrect.height() * factor);
isFit = false;
update(true);
repaintCanvas(true);
setRectToLines();
}
@@ -662,8 +667,8 @@ void Graphic::fullscreen() {
void Graphic::canvasLeaveEvent(QEvent *) {
isHover = false;
if (guides) update(true);
ui->status->setText(tr("Cursor") + ": ( ; )");
if (guides) repaintCanvas(true);
if (ui->status->isVisible()) ui->status->setText(tr("Cursor") + ": ( ; )");
leaveFullscreen();
}
@@ -685,14 +690,19 @@ void Graphic::clear() {
graphics[i].max_x = 0.;
graphics[i].cvrect = QRectF();
}
if (isFit) on_graphic_buttonAutofit_clicked();
if (isFit) autofit();
}
void Graphic::setAntialiasing(bool enabled) {
if (aalias == enabled) return;
aalias = enabled;
update();
repaintCanvas();
}
void Graphic::setAutoUpdate(bool enabled) {
aupdate = enabled;
}
@@ -706,7 +716,7 @@ void Graphic::setPaused(bool yes) {
if (!pause_) {
killTimer(timer_pause);
timer_pause = 0;
update(true);
repaintCanvas(true);
return;
}
for (int i = 0; i < graphics.size(); ++i) {
@@ -739,7 +749,57 @@ void Graphic::setHistorySize(double val) {
void Graphic::setMaxVisibleTime(double val) {
visible_time = val;
if (isFit) on_graphic_buttonAutofit_clicked();
if (isFit) autofit();
}
void Graphic::setAutoXIncrement(double val) {
inc_x = val;
}
void Graphic::setLimit(const QRectF & val) {
limit_ = val;
}
void Graphic::setMargins(const QRect & val) {
margins_ = val;
repaintCanvas();
}
void Graphic::setMargins(int left_, int right_, int top_, int bottom_) {
setMargins(QRect(left_, bottom_, right_, top_));
}
void Graphic::setLeftMargin(int value) {
margins_.moveLeft(value);
setMargins(margins_);
}
void Graphic::setRightMargin(int value) {
margins_.setWidth(value);
setMargins(margins_);
}
void Graphic::setTopMargin(int value) {
margins_.setHeight(value);
setMargins(margins_);
}
void Graphic::setBottomMargin(int value) {
margins_.moveTop(value);
setMargins(margins_);
}
void Graphic::setMinimumRepaintInterval(const int & val) {
min_repaint_int = val;
}
@@ -777,8 +837,9 @@ QByteArray Graphic::graphicsDataRaw() const {
void Graphic::setGraphicsData(const Graphic::GraphicsData & gd) {
setGraphicsCount(gd.size());
for (int i = 0; i < gd.size(); ++i)
for (int i = 0; i < gd.size(); ++i) {
setGraphicData(gd[i], i, false);
}
updateGraphics();
}
@@ -795,6 +856,62 @@ void Graphic::setGraphicsDataRaw(const QByteArray & ba) {
}
void Graphic::setGridNumbersMultiplierX(double value) {
grid_numbers_x = value;
updateGraphics();
}
void Graphic::setGridNumbersMultiplierY(double value) {
grid_numbers_y = value;
updateGraphics();
}
void Graphic::setGraduationX(Graduation value) {
grad_x = value;
updateGraphics();
}
void Graphic::setGraduationY(Graduation value) {
grad_y = value;
updateGraphics();
}
void Graphic::setGraduationStepX(double sx) {
gridx = sx;
updateGraphics();
}
void Graphic::setGraduationStepY(double sy) {
gridy = sy;
if (aupdate) repaintCanvas();
}
void Graphic::setGraduationSteps(double sx, double sy) {
gridx = sx;
gridy = sy;
if (aupdate) repaintCanvas();
}
void Graphic::setAxisType(AxisType t) {
axis_type_x = t;
if (aupdate) repaintCanvas();
}
void Graphic::setFloatingAxisType(FloatingAxisType t) {
floating_axis_type = t;
setGuidesCursor();
if (aupdate) repaintCanvas();
}
void Graphic::setFloatingAxisEnabled(bool on) {
ui->graphic_checkGuides->setChecked(on);
}
@@ -803,23 +920,24 @@ void Graphic::setFloatingAxisEnabled(bool on) {
void Graphic::setButtons(Graphic::Buttons b) {
buttons_ = b;
ui->graphic_buttonAutofit->setVisible(b.testFlag(Autofit));
ui->graphic_checkGrid->setVisible(b.testFlag(Grid));
ui->graphic_checkGuides->setVisible(b.testFlag(CursorAxis));
ui->graphic_buttonFullscreen->setVisible(b.testFlag(Fullscreen));
ui->graphic_checkBorderInputs->setVisible(b.testFlag(BorderInputs));
ui->graphic_checkLegend->setVisible(b.testFlag(Legend));
ui->graphic_buttonClear->setVisible(b.testFlag(Clear));
ui->graphic_buttonConfigure->setVisible(b.testFlag(Configure));
ui->graphic_buttonSave->setVisible(b.testFlag(Save));
ui->graphic_buttonExport->setVisible(b.testFlag(Export));
ui->graphic_buttonSaveMenu->setVisible(b.testFlag(Save) || b.testFlag(Export));
ui->graphic_actionExportCSV->setVisible(b.testFlag(Export));
ui->graphic_actionSaveImage->setVisible(b.testFlag(Save));
ui->graphic_buttonClose->setVisible(b.testFlag(Close));
ui->graphic_checkPause->setVisible(b.testFlag(Pause));
ui->graphic_buttonRecord->setVisible(b.testFlag(Record));
if (ui->graphic_buttonAutofit->isVisible() || ui->graphic_checkGrid->isVisible() || ui->graphic_checkGuides->isVisible() ||
ui->graphic_buttonConfigure->isVisible() || ui->graphic_buttonSave->isVisible() || ui->graphic_checkPause->isVisible())
if (ui->graphic_buttonAutofit->isVisible() || ui->graphic_checkGuides->isVisible() || ui->graphic_buttonConfigure->isVisible() ||
ui->graphic_checkPause->isVisible()) {
ui->verticalSpacer->changeSize(0, 30, QSizePolicy::Preferred, QSizePolicy::Preferred);
else
} else {
ui->verticalSpacer->changeSize(0, 0, QSizePolicy::Preferred, QSizePolicy::Preferred);
}
ui->layoutButtons->update();
}
@@ -860,6 +978,35 @@ void Graphic::addPoint(const QPointF & p, int graphic, bool update_) {
}
void Graphic::addPoint(const QPointF & p, bool update) {
addPoint(p, curGraphic, update);
}
void Graphic::addPoint(double x, double y, int graphic, bool update) {
addPoint(QPointF(x, y), graphic, update);
}
void Graphic::addPoint(double x, double y, bool update) {
addPoint(QPointF(x, y), update);
}
void Graphic::addPoint(double y, int graphic, bool update) {
if (graphics[graphic].polyline.isEmpty()) {
addPoint(QPointF(0.0, y), graphic, update);
} else {
addPoint(QPointF(graphics[graphic].max_x + inc_x, y), graphic, update);
}
}
void Graphic::addPoint(double y, bool update) {
addPoint(y, curGraphic, update);
}
void Graphic::addPoints(const QPolygonF & pts, int graphic, bool update_) {
if (graphic >= graphics.size() || graphic < 0 || pts.isEmpty()) return;
GraphicType & t(graphics[graphic]);
@@ -872,24 +1019,36 @@ void Graphic::addPoints(const QPolygonF & pts, int graphic, bool update_) {
}
}
if (t.polyline.size() == 0) t.max_x = pts.at(0).x();
for (const QPointF & p: pts)
for (const QPointF & p: pts) {
if (t.max_x < p.x()) t.max_x = p.x();
}
t.polyline << pts;
tick(graphic, true, update_);
}
void Graphic::addPoints(const QPolygonF & pts, bool update) {
addPoints(pts, curGraphic, update);
}
void Graphic::addPoints(const QVector<double> & pts, int graphic, bool update_) {
QPolygonF ps;
ps.reserve(pts.size());
double stx = 0;
if (!graphics[curGraphic].polyline.isEmpty()) stx = graphics[curGraphic].max_x;
for (int i = 0; i < pts.size(); ++i)
for (int i = 0; i < pts.size(); ++i) {
ps << QPointF(stx + i * inc_x, pts[i]);
}
addPoints(ps, graphic, update_);
}
void Graphic::addPoints(const QVector<double> & pts, bool update) {
addPoints(pts, curGraphic, update);
}
void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic, bool update_) {
if (graphic >= graphics.size() || graphic < 0) return;
GraphicType & t(graphics[graphic]);
@@ -902,12 +1061,23 @@ void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic, bool updat
return;
}
t.max_x = t.polyline[0].x();
for (int i = 1; i < t.polyline.size(); ++i)
if (t.max_x < t.polyline[i].x()) t.max_x = t.polyline[i].x();
for (const auto & p: t.polyline) {
if (t.max_x < p.x()) t.max_x = p.x();
}
tick(graphic, false, update_);
}
void Graphic::setGraphicData(const QVector<QPointF> & g) {
setGraphicData(g, curGraphic);
}
void Graphic::setGraphicProperties(const QString & name, const QColor & color, Qt::PenStyle style, double width, bool visible) {
setGraphicProperties(curGraphic, name, color, style, width, visible);
}
void Graphic::setGraphicProperties(int graphic,
const QString & name,
const QColor & color,
@@ -925,15 +1095,21 @@ void Graphic::setGraphicProperties(int graphic,
void Graphic::addGraphic(const QString & name, const QColor & color, Qt::PenStyle style, double width, bool visible) {
graphics << GraphicType(name, color, style, width, visible);
addGraphic(GraphicType(name, color, style, width, visible));
}
void Graphic::addGraphic(const GraphicType & gd) {
graphics << gd;
updateLegend();
repaintCanvas();
}
void Graphic::setVisualRect(const QRectF & rect) {
selrect = rect;
isFit = false;
update();
repaintCanvas();
}
@@ -943,12 +1119,28 @@ void Graphic::setDefaultRect(const QRectF & rect) {
}
void Graphic::autofit() {
isFit = true;
bool isEmpty = true;
for (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();
repaintCanvas();
}
void Graphic::saveImage(QString filename) {
ppath = filename;
QPixmap im(canvas->size());
canvas->render(&im);
im.save(ppath);
update(true);
}
@@ -1036,12 +1228,23 @@ void Graphic::setOpenGL(bool on) {
ui->canvas_raster->show();
canvas = ui->canvas_raster;
#endif
update();
repaintCanvas();
}
void Graphic::update(bool force) {
repaintCanvas(force);
void Graphic::update() {
repaintCanvas();
}
void Graphic::updateGraphics() {
findGraphicsRect();
repaintCanvas(true);
}
void Graphic::setCurrentGraphic(int arg) {
if (arg < 0 || arg >= graphics.size()) return;
curGraphic = arg;
}
@@ -1478,7 +1681,9 @@ void Graphic::fillDateFormats() {
void Graphic::drawGraphics() {
if (isHover) ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
if (isHover && ui->status->isVisible()) {
ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
}
QPointF srp = -selrect.topLeft();
double sclx, scly, wid = canvas->width(), hei = canvas->height();
int cwid = (wid - gridborder.x() - margins_.left() - margins_.width());
@@ -1606,33 +1811,6 @@ void Graphic::drawGuides() {
QString str;
str = pointCoords(rpos) + fp_size;
bool trace_found = false;
auto trace_axis_func = [&](bool on_x, double cursor) {
if (curTrace >= 0 && curTrace < graphics.size()) {
auto & t(graphics[curTrace]);
if (t.visible) {
QPolygonF & src_pol(pause_ ? t.polyline_pause : t.polyline);
QVector<QPolygonF> & src_lod(pause_ ? t._lod_pause : t._lod);
QPolygonF & pol(t.last_lod == 0 ? src_pol : src_lod[t.last_lod - 1]);
double min_dist = -1, dist = 0.;
int index = -1;
for (int i = 0; i < pol.size(); ++i) {
if (!selrect.contains(pol[i])) continue;
dist = qAbs<double>((on_x ? pol[i].x() : pol[i].y()) - cursor);
if (min_dist > dist || min_dist < 0) {
min_dist = dist;
index = i;
}
}
if (index >= 0) {
rpos = pol[index];
apos = real2canvas(rpos).toPoint();
str = pointCoords(pol[index]) + fp_size;
trace_found = true;
emit graphicTraceEvent(curTrace, rpos);
}
}
}
};
auto trace_free_func = [&](QPointF cursor) {
double min_dist = -1;
int gr = -1, mag_dist = fontHeight(this) * 2;
@@ -1667,11 +1845,8 @@ void Graphic::drawGuides() {
emit graphicTraceEvent(gr, rpos);
}
};
switch (floating_axis_type) {
case TraceXY: trace_free_func(rpos); break;
case TraceX: trace_axis_func(true, rpos.x()); break;
case TraceY: trace_axis_func(false, rpos.y()); break;
default: break;
if (floating_axis_type == Trace) {
trace_free_func(rpos);
}
if (was_trace && !trace_found) emit graphicTraceEvent(-1, QPointF());
was_trace = trace_found;
@@ -1823,49 +1998,70 @@ void Graphic::addDateTime(QDateTime & dt, int * c, qint64 mul) {
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;
int gbx = gridborder.x() + margins_.left();
int wid = lastw - gbx - margins_.width();
double cx = px - gbx;
double sclx = selrect.width() / (double)wid;
return cx * sclx + selrect.x();
}
double Graphic::canvas2realY(double py) const {
int gby = gridborder.y() + margins_.top(), chei = lasth, hei = chei - gby - margins_.height();
double cy = chei - py - gby, scly = selrect.height() / (double)hei;
int gby = gridborder.y() + margins_.top();
int hei = lasth - gby - margins_.height();
double cy = lasth - py - gby;
double 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();
int gbx = gridborder.x() + margins_.left();
int wid = lastw - 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, hei = chei - gby - margins_.height();
int gby = gridborder.y() + margins_.top();
int hei = lasth - gby - margins_.height();
double scly = selrect.height() / (double)hei;
return chei - gby - (py - selrect.y()) / scly;
return lasth - gby - (py - selrect.y()) / scly;
}
QPolygonF Graphic::real2canvas(const QPolygonF & real_polygon) const {
QPolygonF ret;
for (int i = 0; i < real_polygon.size(); ++i)
ret << real2canvas(real_polygon[i]);
for (const auto & p: real_polygon) {
ret << real2canvas(p);
}
return ret;
}
QPolygonF Graphic::canvas2real(const QPolygonF & canvas_polygon) const {
QPolygonF ret;
for (int i = 0; i < canvas_polygon.size(); ++i)
ret << canvas2real(canvas_polygon[i]);
for (const auto & p: canvas_polygon) {
ret << canvas2real(p);
}
return ret;
}
double Graphic::getScaleX() const {
int gbx = gridborder.x() + margins_.left();
int wid = lastw - gbx - margins_.width();
return selrect.width() / (double)wid;
}
double Graphic::getScaleY() const {
int gby = gridborder.y() + margins_.top();
int hei = lasth - gby - margins_.height();
return selrect.height() / (double)hei;
}
void Graphic::setCurrentAction(GraphicAction action) {
curaction = action;
switch (action) {
@@ -1939,10 +2135,10 @@ void Graphic::setRectToLines() {
else
line_y_max.setValue(selrect.top());
}
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.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.blockSignals(false);
line_x_max.blockSignals(false);
line_y_min.blockSignals(false);
@@ -1954,7 +2150,7 @@ void Graphic::setRectToLines() {
void Graphic::checkLines() {
isFit = (line_x_min.isCleared() && line_x_max.isCleared() && line_y_min.isCleared() && line_y_max.isCleared());
update(true);
repaintCanvas(true);
}
@@ -1977,16 +2173,8 @@ void Graphic::tick(int index, bool slide, bool update_) {
} else {
calcLOD(index);
}
if (!update_) {
if (isFit) findGraphicsRect();
return;
}
if (isFit) findGraphicsRect();
if (!slide) {
if (aupdate) update();
return;
}
if (aupdate) update();
if (aupdate && update_) repaintCanvas();
}
@@ -2036,20 +2224,15 @@ void Graphic::calcLOD(int index) {
}
void Graphic::repaintCanvas(bool force) {
if (tm.elapsed() < min_repaint_int && !force) return;
tm.restart();
canvas->update();
}
void Graphic::on_graphic_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();
autofit();
}
@@ -2074,6 +2257,7 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
conf->ui->checkInputs->setChecked(borderInputsVisible());
conf->ui->checkStatus->setChecked(statusVisible());
conf->ui->checkLegend->setChecked(legendVisible());
conf->ui->groupGrid->setChecked(grid);
conf->ui->checkGridAutoX->setChecked(grad_x == Auto);
conf->ui->checkGridAutoY->setChecked(grad_y == Auto);
conf->ui->colorBackground->setColor(back_color);
@@ -2102,12 +2286,18 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
conf->ui->spinMarginR->value(),
conf->ui->spinMarginT->value(),
conf->ui->spinMarginB->value());
setGridEnabled(conf->ui->groupGrid->isChecked());
updateLegend();
update();
repaintCanvas();
}
void Graphic::on_graphic_buttonSave_clicked() {
void Graphic::on_graphic_buttonFullscreen_clicked() {
fullscreen();
}
void Graphic::on_graphic_actionSaveImage_triggered() {
QString f = QFileDialog::getSaveFileName(this,
tr("Save Image"),
ppath,
@@ -2117,7 +2307,7 @@ void Graphic::on_graphic_buttonSave_clicked() {
}
void Graphic::on_graphic_buttonExport_clicked() {
void Graphic::on_graphic_actionExportCSV_triggered() {
QString f = QFileDialog::getSaveFileName(this, tr("Export graphics"), ppath, "CSV(*.csv)");
if (f.isEmpty()) return;
QStringList items;
@@ -2169,7 +2359,7 @@ void Graphic::on_graphic_buttonRecord_clicked(bool checked) {
void Graphic::on_graphic_checkGuides_toggled(bool checked) {
guides = checked;
setGuidesCursor();
update();
repaintCanvas();
}
@@ -2231,15 +2421,6 @@ void Graphic::updateLegend(bool es) {
check->show();
if (leg_sa->minimum_hei == 0) {
leg_sa->minimum_hei = ui->widgetLegend->sizeHint().height();
/*#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QTimer::singleShot(0, this, [this,leg_sa,check](){
leg_sa->minimum_hei = check->sizeHint().height();
leg_sa->updateGeometry();
qDebug() << leg_sa->minimum_hei << ui->widgetLegend->sizeHint();
});
#else
leg_sa->minimum_hei = check->sizeHint().height();
#endif*/
}
col++;
if (col > maxcol) {
@@ -2250,7 +2431,6 @@ void Graphic::updateLegend(bool es) {
ui->gridLayout->invalidate();
ui->scrollLegend->setVisible(lv);
leg_sa->updateGeometry();
// ui->gridLayout->invalidate();
leg_update = true;
if (es) emit graphicSettingsChanged();
}
@@ -2273,9 +2453,9 @@ void Graphic::graphicVisibleChange(bool checked) {
int i = cb->property("graphic_num").toInt();
graphics[i].visible = checked;
if (isFit)
on_graphic_buttonAutofit_clicked();
autofit();
else {
update();
repaintCanvas();
}
emit graphicSettingsChanged();
}
@@ -2289,14 +2469,49 @@ void Graphic::graphicAllVisibleChange(bool checked) {
}
visible_update = false;
if (isFit)
on_graphic_buttonAutofit_clicked();
autofit();
else {
update();
repaintCanvas();
}
emit graphicSettingsChanged();
}
void Graphic::lineXMinChanged(double value) {
selrect.setLeft(value);
checkLines();
}
void Graphic::lineXMaxChanged(double value) {
selrect.setRight(value);
checkLines();
}
void Graphic::lineYMinChanged(double value) {
selrect.setBottom(value);
checkLines();
}
void Graphic::lineYMaxChanged(double value) {
selrect.setTop(value);
checkLines();
}
void Graphic::on_graphic_buttonClose_clicked() {
emit closeRequest(this);
}
void Graphic::on_graphic_buttonClear_clicked() {
clear();
emit cleared();
}
void Graphic::enterFullscreen() {
if (fullscr) return;
fullscr = true;
@@ -2398,13 +2613,15 @@ QByteArray Graphic::save() {
if (backgroundColor() == palette().color(QPalette::Base) && textColor() == palette().color(QPalette::WindowText) &&
gridColor() == palette().color(QPalette::Disabled, QPalette::WindowText))
cs.add(17, true);
cs.add(18, gridEnabled());
return cs.data().prepend('2');
}
void Graphic::load(QByteArray ba) {
if (ba.isEmpty()) return;
char ver = ba[0];
char ver = ba[0];
bool has_opengl = isOGL;
switch (ver) {
case '2': { // version '2':
ba.remove(0, 1);
@@ -2413,36 +2630,37 @@ void Graphic::load(QByteArray ba) {
bool def_colors = false;
while (!cs.atEnd()) {
switch (cs.read()) {
case 1: setAntialiasing(cs.getData<bool>()); break;
case 2: setOpenGL(cs.getData<bool>()); break;
case 1: aalias = cs.getData<bool>(); break;
case 2: has_opengl = cs.getData<bool>(); break;
case 3: setBorderInputsVisible(cs.getData<bool>()); break;
case 4: setStatusVisible(cs.getData<bool>()); break;
case 5: setLegendVisible(cs.getData<bool>()); break;
case 6:
if (!def_colors) setBackgroundColor(cs.getData<QColor>());
if (!def_colors) back_color = cs.getData<QColor>();
break;
case 7:
if (!def_colors) setTextColor(cs.getData<QColor>());
if (!def_colors) text_color = cs.getData<QColor>();
break;
case 8: setMargins(cs.getData<QRect>()); break;
case 8: margins_ = cs.getData<QRect>(); break;
case 9:
if (!def_colors) setGridPen(cs.getData<QPen>());
if (!def_colors) grid_pen = cs.getData<QPen>();
break;
case 10: setGraduationX(cs.getData<Graduation>()); break;
case 11: setGraduationY(cs.getData<Graduation>()); break;
case 12: setGraduationStepX(cs.getData<double>()); break;
case 13: setGraduationStepY(cs.getData<double>()); break;
case 10: grad_x = cs.getData<Graduation>(); break;
case 11: grad_y = cs.getData<Graduation>(); break;
case 12: gridx = cs.getData<double>(); break;
case 13: gridy = cs.getData<double>(); break;
case 14: graphics = cs.getData<QVector<GraphicType>>(); break;
case 15: isFit = cs.getData<bool>(); break;
case 16: vrect = cs.getData<QRectF>(); break;
case 17:
if (cs.getData<bool>()) {
setTextColor(palette().color(QPalette::WindowText));
setGridPen(QPen(palette().color(QPalette::Disabled, QPalette::WindowText), 0., Qt::DotLine));
setBackgroundColor(palette().color(QPalette::Base));
text_color = palette().color(QPalette::WindowText);
grid_pen = QPen(palette().color(QPalette::Disabled, QPalette::WindowText), 0., Qt::DotLine);
back_color = palette().color(QPalette::Base);
def_colors = true;
}
break;
case 18: grid = cs.getData<bool>(); break;
default: break;
}
}
@@ -2451,10 +2669,8 @@ void Graphic::load(QByteArray ba) {
default: { // old version 0:
QDataStream s(ba);
bool a;
s >> a;
setOpenGL(a);
s >> a;
setAntialiasing(a);
s >> has_opengl;
s >> aalias;
s >> a;
setBorderInputsVisible(a);
s >> a;
@@ -2464,28 +2680,253 @@ void Graphic::load(QByteArray ba) {
setLegendVisible(a);
} break;
}
if (has_opengl != isOGL) setOpenGL(has_opengl);
updateLegend();
repaintCanvas(true);
}
GraphicType Graphic::graphic(int arg) {
if (arg < 0 || arg >= graphics.size()) return GraphicType();
return graphics[arg];
}
void Graphic::setAllGraphics(const QVector<GraphicType> & g, bool update) {
graphics = g;
if (update) {
updateLegend();
repaintCanvas();
}
}
void Graphic::setCaption(const QString & str) {
ui->labelCaption->setText(str);
ui->labelCaption->setVisible(str.length() > 0);
if (aupdate) update();
if (aupdate) repaintCanvas();
}
void Graphic::setLabelX(const QString & str) {
label_x = str;
hasLblX = (str.length() > 0);
if (aupdate) repaintCanvas();
}
void Graphic::setLabelY(const QString & str) {
label_y = str;
hasLblY = (str.length() > 0);
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicName(const QString & str, int index) {
graphics[index].name = str;
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicName(const QString & str) {
graphics[curGraphic].name = str;
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setBackgroundColor(const QColor & color) {
back_color = color;
if (aupdate) repaintCanvas();
updateLegend();
}
void Graphic::setTextColor(const QColor & color) {
text_color = color;
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicColor(const QColor & color, int index) {
graphics[index].pen.setColor(color);
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicColor(const QColor & color) {
setGraphicColor(color, curGraphic);
}
void Graphic::setGridColor(const QColor & color) {
grid_pen.setColor(color);
if (aupdate) repaintCanvas();
}
void Graphic::setSelectionColor(const QColor & color) {
selpen.setColor(color);
}
void Graphic::setGraphicStyle(const Qt::PenStyle & style, int index) {
graphics[index].pen.setStyle(style);
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicStyle(const Qt::PenStyle & style) {
setGraphicStyle(style, curGraphic);
}
void Graphic::setGridStyle(const Qt::PenStyle & style) {
grid_pen.setStyle(style);
if (aupdate) repaintCanvas();
}
void Graphic::setSelectionStyle(const Qt::PenStyle & style) {
selpen.setStyle(style);
}
void Graphic::setGraphicVisible(bool visible, int index) {
graphics[index].visible = visible;
updateLegendChecks();
if (isFit)
on_graphic_buttonAutofit_clicked();
else if (aupdate)
update();
if (isFit) {
autofit();
} else if (aupdate) {
repaintCanvas();
}
}
void Graphic::setGraphicVisible(bool visible) {
setGraphicVisible(visible, curGraphic);
}
void Graphic::setGraphicLineWidth(double w, int index) {
if (qRound(w) == w)
graphics[index].pen.setWidth(qRound(w));
else
graphics[index].pen.setWidthF(w);
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicLineWidth(double w) {
setGraphicLineWidth(w, curGraphic);
}
void Graphic::setGraphicPointWidth(double w, int index) {
graphics[index].pointWidth = w;
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicPointWidth(double w) {
setGraphicPointWidth(w, curGraphic);
}
void Graphic::setGraphicFillColor(const QColor & w, int index) {
graphics[index].fill_color = w;
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicFillColor(const QColor & w) {
setGraphicFillColor(w, curGraphic);
}
void Graphic::setGraphicLinesEnabled(bool w, int index) {
graphics[index].lines = w;
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicLinesEnabled(bool w) {
setGraphicLinesEnabled(w, curGraphic);
}
void Graphic::setGraphicPointsEnabled(bool w, int index) {
graphics[index].points = w;
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicPointsEnabled(bool w) {
setGraphicPointsEnabled(w, curGraphic);
}
void Graphic::setGraphicFillEnabled(bool w, int index) {
graphics[index].fill = w;
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicFillEnabled(bool w) {
setGraphicFillEnabled(w, curGraphic);
}
void Graphic::setGraphicPen(const QPen & pen, int index) {
graphics[index].pen = pen;
updateLegend();
if (aupdate) repaintCanvas();
}
void Graphic::setGraphicPen(const QPen & pen) {
setGraphicPen(pen, curGraphic);
}
void Graphic::setGridPen(const QPen & pen) {
grid_pen = pen;
if (aupdate) repaintCanvas();
}
void Graphic::setSelectionPen(const QPen & pen) {
selpen = pen;
}
void Graphic::setSelectionBrush(const QBrush & brush) {
selbrush = brush;
}
void Graphic::setNavigationEnabled(bool on) {
navigation = on;
}
void Graphic::setLODOptimization(bool yes) {
m_LODOptimization = yes;
}
void Graphic::setGridEnabled(bool enabled) {
ui->graphic_checkGrid->setChecked(enabled);
grid = enabled;
repaintCanvas();
}
@@ -2525,6 +2966,21 @@ void Graphic::on_graphic_actionExpandY_triggered(bool checked) {
}
void Graphic::on_graphic_checkBorderInputs_toggled(bool checked) {
setBorderInputsVisible(checked);
}
void Graphic::on_graphic_checkLegend_toggled(bool checked) {
setLegendVisible(checked);
}
void Graphic::on_graphic_checkPause_toggled(bool checked) {
setPaused(checked);
}
void Graphic::actionGuidesTriggered(QAction * a) {
ui->graphic_checkGuides->setChecked(true);
setFloatingAxisType((FloatingAxisType)a->property("_value").toInt());

View File

@@ -167,9 +167,7 @@ public:
};
enum FloatingAxisType {
Free,
TraceXY,
TraceX,
TraceY
Trace
};
Q_DECLARE_FLAGS(Buttons, Button)
@@ -222,7 +220,6 @@ public:
bool LODOptimization() const { return m_LODOptimization; }
bool isAutofitted() const { return isFit; }
int currentGraphic() const { return curGraphic; }
int currentTraceGraphic() const { return curTrace; }
int graphicsCount() const { return graphics.size(); }
Graphic::Buttons buttons() const { return buttons_; }
Graphic::Alignment buttonsPosition() const { return align; }
@@ -247,18 +244,13 @@ public:
GraphicsData graphicsData() const;
QByteArray graphicsDataRaw() const;
QWidget * viewport() const { return canvas; }
QByteArray save();
void load(QByteArray ba);
GraphicType graphic(int arg) {
if (arg < 0 || arg >= graphics.size()) return GraphicType();
return graphics[arg];
}
GraphicType graphic(int arg);
const QVector<GraphicType> & allGraphics() const { return graphics; }
void setAllGraphics(const QVector<GraphicType> & g, bool update = true) {
graphics = g;
if (update) updateLegend();
}
void setAllGraphics(const QVector<GraphicType> & g, bool update = true);
double canvas2realX(double px) const;
double canvas2realY(double py) const;
@@ -268,121 +260,50 @@ public:
QPointF real2canvas(QPointF real_point) const { return QPointF(real2canvasX(real_point.x()), real2canvasY(real_point.y())); }
QPolygonF real2canvas(const QPolygonF & real_polygon) const;
QPolygonF canvas2real(const QPolygonF & canvas_polygon) const;
double getScaleX() const { return real2canvasX(1.) - real2canvasX(0.); }
double getScaleY() const { return real2canvasY(1.) - real2canvasY(0.); }
double getScaleX() const;
double getScaleY() const;
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, int index) {
graphics[index].pen.setStyle(style);
updateLegend();
if (aupdate) update();
}
void setGraphicStyle(const Qt::PenStyle & style) { setGraphicStyle(style, curGraphic); }
void setGridStyle(const Qt::PenStyle & style) {
grid_pen.setStyle(style);
if (aupdate) update();
}
void setSelectionStyle(const Qt::PenStyle & style) { selpen.setStyle(style); }
void setLabelX(const QString & str);
void setLabelY(const QString & str);
void setGraphicName(const QString & str, int index);
void setGraphicName(const QString & str);
void setBackgroundColor(const QColor & color);
void setTextColor(const QColor & color);
void setGraphicColor(const QColor & color, int index);
void setGraphicColor(const QColor & color);
void setGridColor(const QColor & color);
void setSelectionColor(const QColor & color);
void setGraphicStyle(const Qt::PenStyle & style, int index);
void setGraphicStyle(const Qt::PenStyle & style);
void setGridStyle(const Qt::PenStyle & style);
void setSelectionStyle(const Qt::PenStyle & style);
void setGraphicVisible(bool visible, int index);
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 setLODOptimization(bool yes) { m_LODOptimization = yes; }
void setGraphicVisible(bool visible);
void setGraphicLineWidth(double w, int index);
void setGraphicLineWidth(double w);
void setGraphicPointWidth(double w, int index);
void setGraphicPointWidth(double w);
void setGraphicFillColor(const QColor & w, int index);
void setGraphicFillColor(const QColor & w);
void setGraphicLinesEnabled(bool w, int index);
void setGraphicLinesEnabled(bool w);
void setGraphicPointsEnabled(bool w, int index);
void setGraphicPointsEnabled(bool w);
void setGraphicFillEnabled(bool w, int index);
void setGraphicFillEnabled(bool w);
void setGraphicPen(const QPen & pen, int index);
void setGraphicPen(const QPen & pen);
void setGridPen(const QPen & pen);
void setSelectionPen(const QPen & pen);
void setSelectionBrush(const QBrush & brush);
void setNavigationEnabled(bool on);
void setLODOptimization(bool yes);
void setOpenGL(bool on);
void setAntialiasing(bool enabled);
void setAutoUpdate(bool enabled) { aupdate = enabled; }
void setAutoUpdate(bool enabled);
void setGridEnabled(bool enabled);
void setBorderInputsVisible(bool visible);
void setStatusVisible(bool visible);
@@ -392,107 +313,49 @@ public slots:
void setButtonsPosition(Graphic::Alignment a);
void setHistorySize(double val);
void setMaxVisibleTime(double 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 setAutoXIncrement(double val);
void setLimit(const QRectF & val);
void setMargins(const QRect & val);
void setMargins(int left_, int right_, int top_, int bottom_);
void setLeftMargin(int value);
void setRightMargin(int value);
void setTopMargin(int value);
void setBottomMargin(int value);
void setMinimumRepaintInterval(const int & val);
void setOnlyExpandY(bool yes);
void setOnlyExpandX(bool yes);
void setGesturesNavigation(bool yes);
void setGraphicsData(const GraphicsData & gd);
void setGraphicsDataRaw(const QByteArray & ba);
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 setFloatingAxisType(FloatingAxisType t) {
floating_axis_type = t;
setGuidesCursor();
if (aupdate) update();
}
void setGridNumbersMultiplierX(double value);
void setGridNumbersMultiplierY(double value);
void setGraduationX(Graduation value);
void setGraduationY(Graduation value);
void setGraduationStepX(double sx);
void setGraduationStepY(double sy);
void setGraduationSteps(double sx, double sy);
void setAxisType(AxisType t);
void setFloatingAxisType(FloatingAxisType t);
void setFloatingAxisEnabled(bool on);
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) {
if (graphics[graphic].polyline.isEmpty())
addPoint(QPointF(0.0, y), graphic, update);
else
addPoint(QPointF(graphics[graphic].max_x + inc_x, y), graphic, update);
}
void addPoint(double y, bool update = true) {
if (graphics[curGraphic].polyline.isEmpty())
addPoint(QPointF(0.0, y), update);
else
addPoint(QPointF(graphics[curGraphic].max_x + inc_x, y), update);
}
void addPoint(const QPointF & p, bool update = true);
void addPoint(double x, double y, int graphic, bool update = true);
void addPoint(double x, double y, bool update = true);
void addPoint(double y, int graphic, bool update = true);
void addPoint(double y, bool update = true);
void addPoints(const QPolygonF & pts, int graphic, bool update_ = true);
void addPoints(const QPolygonF & pts, bool update = true) { addPoints(pts, curGraphic, update); }
void addPoints(const QPolygonF & pts, bool update = true);
void addPoints(const QVector<double> & pts, int graphic, bool update_ = true);
void addPoints(const QVector<double> & pts, bool update = true) { addPoints(pts, curGraphic, update); }
void addPoints(const QVector<double> & pts, bool update = true);
void setGraphicData(const QVector<QPointF> & g, int graphic, bool update_ = true);
void setGraphicData(const QVector<QPointF> & g) { setGraphicData(g, curGraphic); }
void setGraphicData(const QVector<QPointF> & g);
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);
}
bool visible = true);
void setGraphicProperties(int graphic,
const QString & name,
const QColor & color = Qt::darkRed,
@@ -504,30 +367,16 @@ public slots:
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 addGraphic(const GraphicType & gd);
void setVisualRect(const QRectF & rect);
void setDefaultRect(const QRectF & rect);
void autofit() { on_graphic_buttonAutofit_clicked(); }
void autofit();
void saveImage(QString filename);
void exportGraphics(QString filename, QChar decimal_point);
void clear();
void update(bool force);
void update() { update(false); }
void updateGraphics() {
findGraphicsRect();
update();
}
void setCurrentGraphic(int arg) {
if (arg < 0 || arg >= graphics.size()) return;
curGraphic = arg;
}
void setTraceGraphic(int arg) {
if (arg < 0 || arg >= graphics.size()) return;
curTrace = arg;
}
void update();
void updateGraphics();
void setCurrentGraphic(int arg);
void setGraphicsCount(int arg, bool update = true);
void removeGraphic(int arg, bool update = true);
void setCustomGridMarkFuncs(std::function<QString(double val)> fx, std::function<QString(double val)> fy);
@@ -560,11 +409,7 @@ protected:
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 calcLOD(int index);
void repaintCanvas(bool force = false) {
if (tm.elapsed() < min_repaint_int && !force) return;
tm.restart();
canvas->update();
}
void repaintCanvas(bool force = false);
void drawGraphics();
void drawGrid();
void drawGuides();
@@ -597,7 +442,7 @@ protected:
QPen grid_pen, selpen;
QColor back_color, text_color;
QVector<GraphicType> graphics;
int curGraphic, curTrace;
int curGraphic;
GraphicAction curaction, prevaction;
QRectF grect, selrect, limit_, def_rect;
QRect margins_;
@@ -642,43 +487,24 @@ protected slots:
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_graphic_buttonClose_clicked() { emit closeRequest(this); }
void on_graphic_buttonClear_clicked() {
clear();
emit cleared();
}
void lineXMinChanged(double value);
void lineXMaxChanged(double value);
void lineYMinChanged(double value);
void lineYMaxChanged(double value);
void on_graphic_buttonClose_clicked();
void on_graphic_buttonClear_clicked();
void on_graphic_buttonAutofit_clicked();
void on_graphic_buttonConfigure_clicked();
void on_graphic_buttonFullscreen_clicked() { fullscreen(); }
void on_graphic_buttonSave_clicked();
void on_graphic_buttonExport_clicked();
void on_graphic_buttonFullscreen_clicked();
void on_graphic_actionSaveImage_triggered();
void on_graphic_actionExportCSV_triggered();
void on_graphic_buttonRecord_clicked(bool checked);
void on_graphic_checkGrid_toggled(bool checked) {
grid = checked;
update();
}
void on_graphic_checkGuides_toggled(bool checked);
void on_graphic_actionExpandX_triggered(bool checked);
void on_graphic_actionExpandY_triggered(bool checked);
void on_graphic_checkBorderInputs_toggled(bool checked) { setBorderInputsVisible(checked); }
void on_graphic_checkLegend_toggled(bool checked) { setLegendVisible(checked); }
void on_graphic_checkPause_toggled(bool checked) { setPaused(checked); }
void on_graphic_checkBorderInputs_toggled(bool checked);
void on_graphic_checkLegend_toggled(bool checked);
void on_graphic_checkPause_toggled(bool checked);
void actionGuidesTriggered(QAction * a);
void enterFullscreen();
void leaveFullscreen();

View File

@@ -68,23 +68,6 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="graphic_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="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="graphic_checkGuides">
<property name="toolTip">
@@ -167,7 +150,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="graphic_buttonSave">
<widget class="QToolButton" name="graphic_buttonSaveMenu">
<property name="toolTip">
<string>Save image ...</string>
</property>
@@ -175,16 +158,8 @@
<iconset resource="../blockview/qad_blockview.qrc">
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="graphic_buttonExport">
<property name="toolTip">
<string>Export graphics ...</string>
</property>
<property name="icon">
<iconset resource="../blockview/qad_blockview.qrc">
<normaloff>:/icons/document-edit.png</normaloff>:/icons/document-edit.png</iconset>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
</item>
@@ -442,22 +417,6 @@
<string>Free</string>
</property>
</action>
<action name="graphic_actionGuidesTraceX">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Trace X</string>
</property>
</action>
<action name="graphic_actionGuidesTraceY">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Trace Y</string>
</property>
</action>
<action name="graphic_actionExpandX">
<property name="checkable">
<bool>true</bool>
@@ -488,6 +447,24 @@
<string>Snap trace</string>
</property>
</action>
<action name="graphic_actionSaveImage">
<property name="icon">
<iconset resource="../blockview/qad_blockview.qrc">
<normaloff>:/icons/view-preview.png</normaloff>:/icons/view-preview.png</iconset>
</property>
<property name="text">
<string>Save to Image...</string>
</property>
</action>
<action name="graphic_actionExportCSV">
<property name="icon">
<iconset resource="../blockview/qad_blockview.qrc">
<normaloff>:/icons/document-edit.png</normaloff>:/icons/document-edit.png</iconset>
</property>
<property name="text">
<string>Export to CSV...</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@@ -500,9 +477,6 @@
<include location="../application/qad_application.qrc"/>
<include location="../blockview/qad_blockview.qrc"/>
<include location="qad_graphic.qrc"/>
<include location="../application/qad_application.qrc"/>
<include location="../blockview/qad_blockview.qrc"/>
<include location="qad_graphic.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -8,14 +8,14 @@ GraphicConf::GraphicConf(QVector<GraphicType> & graphics_, QWidget * parent): QD
ui = new Ui::GraphicConf();
ui->setupUi(this);
QStringList styles;
int fh = qMax<int>(fontMetrics().size(0, "0").height(), 22);
int fh = qMax<int>(fontMetrics().height(), 22);
int thick = lineThickness(this);
QSize sz(fh * 2.5, fh);
styles << tr("NoPen") << tr("Solid") << tr("Dash") << tr("Dot") << tr("Dash-Dot") << tr("Dash-Dot-Dot");
ui->comboStyleGrid->setIconSize(sz);
ui->comboStyleGraphic->setIconSize(sz);
ui->cbGraphicNames->setIconSize(sz);
for (int i = 0; i < 6; i++) {
for (int i = 0; i < styles.size(); i++) {
QPixmap pix(sz);
pix.fill();
QPainter p(&pix);

View File

@@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>387</width>
<height>505</height>
<height>507</height>
</rect>
</property>
<property name="windowTitle">
@@ -21,7 +21,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="groupAppearence">
<property name="title">
<string>Appearance</string>
</property>
@@ -71,7 +71,7 @@
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="labelBackgroundColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -91,7 +91,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<widget class="QLabel" name="labelTextColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -116,7 +116,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<widget class="QGroupBox" name="groupMargins">
<property name="title">
<string>Margins</string>
</property>
@@ -145,7 +145,7 @@
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="labelAll">
<widget class="QLabel" name="labelMarginAll">
<property name="text">
<string>All:</string>
</property>
@@ -165,7 +165,7 @@
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label_12">
<widget class="QLabel" name="labelMarginRight">
<property name="text">
<string>Right:</string>
</property>
@@ -175,7 +175,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<widget class="QLabel" name="labelMarginLeft">
<property name="text">
<string>Left:</string>
</property>
@@ -185,7 +185,7 @@
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_13">
<widget class="QLabel" name="labelMarginBottom">
<property name="text">
<string>Bottom:</string>
</property>
@@ -205,7 +205,7 @@
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="labelMarginTop">
<property name="text">
<string>Top:</string>
</property>
@@ -215,7 +215,7 @@
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="spinMarginT_2">
<widget class="QSpinBox" name="spinMarginAll">
<property name="suffix">
<string> px</string>
</property>
@@ -230,16 +230,19 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox_3">
<widget class="QGroupBox" name="groupGrid">
<property name="title">
<string>Grid</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="labelGridColor">
<property name="text">
<string>Color:</string>
</property>
@@ -253,7 +256,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="labelGridStyle">
<property name="text">
<string>Style:</string>
</property>
@@ -263,7 +266,7 @@
<widget class="QComboBox" name="comboStyleGrid"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<widget class="QLabel" name="labelGridWidth">
<property name="text">
<string>Width:</string>
</property>
@@ -277,14 +280,14 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<widget class="QLabel" name="labelGridStepX">
<property name="text">
<string>Step X:</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_9">
<widget class="QLabel" name="labelGridStepY">
<property name="text">
<string>Step Y:</string>
</property>
@@ -340,7 +343,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_1">
<widget class="QGroupBox" name="groupGraphics">
<property name="title">
<string>Graphics</string>
</property>
@@ -359,7 +362,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="labelGraphicColor">
<property name="text">
<string>Color:</string>
</property>
@@ -373,7 +376,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="labelGraphicStyle">
<property name="text">
<string>Style:</string>
</property>
@@ -518,7 +521,6 @@
</tabstops>
<resources>
<include location="../../../cd/utils/pult/cdpult.qrc"/>
<include location="../../../cd/utils/pult/cdpult.qrc"/>
</resources>
<connections>
<connection>
@@ -528,8 +530,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>255</x>
<y>641</y>
<x>376</x>
<y>495</y>
</hint>
<hint type="destinationlabel">
<x>245</x>
@@ -544,12 +546,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>322</x>
<y>410</y>
<x>286</x>
<y>373</y>
</hint>
<hint type="destinationlabel">
<x>415</x>
<y>411</y>
<x>366</x>
<y>376</y>
</hint>
</hints>
</connection>
@@ -560,12 +562,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>322</x>
<y>434</y>
<x>291</x>
<y>399</y>
</hint>
<hint type="destinationlabel">
<x>415</x>
<y>435</y>
<x>366</x>
<y>402</y>
</hint>
</hints>
</connection>
@@ -576,8 +578,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>294</x>
<y>641</y>
<x>376</x>
<y>495</y>
</hint>
<hint type="destinationlabel">
<x>288</x>
@@ -592,76 +594,76 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>322</x>
<y>458</y>
<x>245</x>
<y>425</y>
</hint>
<hint type="destinationlabel">
<x>415</x>
<y>460</y>
<x>366</x>
<y>431</y>
</hint>
</hints>
</connection>
<connection>
<sender>spinMarginT_2</sender>
<sender>spinMarginAll</sender>
<signal>valueChanged(int)</signal>
<receiver>spinMarginT</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>259</x>
<y>221</y>
<x>237</x>
<y>209</y>
</hint>
<hint type="destinationlabel">
<x>249</x>
<y>191</y>
<x>237</x>
<y>183</y>
</hint>
</hints>
</connection>
<connection>
<sender>spinMarginT_2</sender>
<sender>spinMarginAll</sender>
<signal>valueChanged(int)</signal>
<receiver>spinMarginR</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>268</x>
<y>220</y>
<x>237</x>
<y>209</y>
</hint>
<hint type="destinationlabel">
<x>371</x>
<y>220</y>
<x>367</x>
<y>209</y>
</hint>
</hints>
</connection>
<connection>
<sender>spinMarginT_2</sender>
<sender>spinMarginAll</sender>
<signal>valueChanged(int)</signal>
<receiver>spinMarginB</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>233</x>
<y>230</y>
<x>237</x>
<y>209</y>
</hint>
<hint type="destinationlabel">
<x>234</x>
<y>252</y>
<x>237</x>
<y>235</y>
</hint>
</hints>
</connection>
<connection>
<sender>spinMarginT_2</sender>
<sender>spinMarginAll</sender>
<signal>valueChanged(int)</signal>
<receiver>spinMarginL</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>213</x>
<y>230</y>
<x>237</x>
<y>209</y>
</hint>
<hint type="destinationlabel">
<x>133</x>
<y>229</y>
<x>106</x>
<y>209</y>
</hint>
</hints>
</connection>

View File

@@ -76,7 +76,7 @@ void MainWindow::redrawGraphics() {
graphic->setGraphicData(pol, i);
}
graphic->setAutoUpdate(true);
graphic->update(true);
graphic->updateGraphics();
}

View File

@@ -151,7 +151,7 @@
<item>
<widget class="QToolButton" name="buttonVarAdd">
<property name="icon">
<iconset resource="../../libs/qglview/qglview.qrc">
<iconset resource="../../libs/widgets/qad_widgets.qrc">
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
</property>
</widget>
@@ -162,7 +162,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/blockview/qad_blockview.qrc">
<iconset resource="../../libs/widgets/qad_widgets.qrc">
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
</property>
<property name="shortcut">
@@ -192,7 +192,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/application/qad_application.qrc">
<iconset resource="../../libs/widgets/qad_widgets.qrc">
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
</property>
</widget>
@@ -272,7 +272,7 @@
<item>
<widget class="QToolButton" name="buttonGraphicAdd">
<property name="icon">
<iconset resource="../../libs/qglview/qglview.qrc">
<iconset resource="../../libs/widgets/qad_widgets.qrc">
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
</property>
</widget>
@@ -283,7 +283,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/blockview/qad_blockview.qrc">
<iconset resource="../../libs/widgets/qad_widgets.qrc">
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
</property>
<property name="shortcut">
@@ -313,7 +313,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/application/qad_application.qrc">
<iconset resource="../../libs/widgets/qad_widgets.qrc">
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
</property>
</widget>
@@ -337,7 +337,7 @@
</widget>
<widget class="Graphic" name="graphic">
<property name="buttons">
<set>Graphic::BorderInputs|Graphic::Configure|Graphic::CursorAxis|Graphic::Export|Graphic::Fullscreen|Graphic::Grid|Graphic::Save</set>
<set>Graphic::BorderInputs|Graphic::Configure|Graphic::CursorAxis|Graphic::Export|Graphic::Fullscreen|Graphic::Save</set>
</property>
<property name="antialiasing">
<bool>true</bool>
@@ -372,13 +372,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="../../libs/application/qad_application.qrc"/>
<include location="../../libs/blockview/qad_blockview.qrc"/>
<include location="../../libs/qglview/qglview.qrc"/>
<include location="qpicalculator.qrc"/>
<include location="../../libs/application/qad_application.qrc"/>
<include location="../../libs/blockview/qad_blockview.qrc"/>
<include location="../../libs/qglview/qglview.qrc"/>
<include location="../../libs/widgets/qad_widgets.qrc"/>
<include location="qpicalculator.qrc"/>
</resources>
<connections/>