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 cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
project(QAD) project(QAD)
set(QAD_MAJOR 2) set(QAD_MAJOR 2)
set(QAD_MINOR 13) set(QAD_MINOR 14)
set(QAD_REVISION 0) set(QAD_REVISION 0)
set(QAD_SUFFIX ) set(QAD_SUFFIX )
set(QAD_COMPANY SHS) 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; func_gridMarkX = func_gridMarkY = nullptr;
ui = new Ui::Graphic(); ui = new Ui::Graphic();
ui->setupUi(this); ui->setupUi(this);
ui->status->hide();
ui->scrollLegend->layout()->addWidget(new LegendScrollArea(ui->widgetLegend)); ui->scrollLegend->layout()->addWidget(new LegendScrollArea(ui->widgetLegend));
ui->scrollLegend->hide(); ui->scrollLegend->hide();
fillDateFormats(); fillDateFormats();
@@ -122,20 +123,16 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
QActionGroup * agroup = new QActionGroup(this); QActionGroup * agroup = new QActionGroup(this);
agroup->addAction(ui->graphic_actionGuidesFree); agroup->addAction(ui->graphic_actionGuidesFree);
agroup->addAction(ui->graphic_actionGuidesTrace); agroup->addAction(ui->graphic_actionGuidesTrace);
agroup->addAction(ui->graphic_actionGuidesTraceX);
agroup->addAction(ui->graphic_actionGuidesTraceY);
ui->graphic_actionGuidesFree->setProperty("_value", (int)Free); ui->graphic_actionGuidesFree->setProperty("_value", (int)Free);
ui->graphic_actionGuidesTrace->setProperty("_value", (int)TraceXY); ui->graphic_actionGuidesTrace->setProperty("_value", (int)Trace);
ui->graphic_actionGuidesTraceX->setProperty("_value", (int)TraceX);
ui->graphic_actionGuidesTraceY->setProperty("_value", (int)TraceY);
ui->graphic_actionGuidesFree->setChecked(true); ui->graphic_actionGuidesFree->setChecked(true);
connect(agroup, SIGNAL(triggered(QAction *)), this, SLOT(actionGuidesTriggered(QAction *))); connect(agroup, SIGNAL(triggered(QAction *)), this, SLOT(actionGuidesTriggered(QAction *)));
ui->graphic_checkGuides->addAction(ui->graphic_actionGuidesFree); ui->graphic_checkGuides->addAction(ui->graphic_actionGuidesFree);
ui->graphic_checkGuides->addAction(ui->graphic_actionGuidesTrace); 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_actionExpandX);
ui->graphic_buttonAutofit->addAction(ui->graphic_actionExpandY); 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_min.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
line_x_max.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())->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; emaxx = emaxy = DBL_MIN;
grad_x = grad_y = Auto; grad_x = grad_y = Auto;
axis_type_x = Numeric; axis_type_x = Numeric;
floating_axis_type = Free; floating_axis_type = Trace;
min_repaint_int = 25; min_repaint_int = 25; // 40 Hz repaint interval
lastw = lasth = 0; lastw = lasth = 0;
inc_x = 1.; inc_x = 1.;
// buffer = 0; // buffer = 0;
@@ -191,7 +188,7 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
text_color = palette().color(QPalette::WindowText); text_color = palette().color(QPalette::WindowText);
grid_pen = QPen(palette().color(QPalette::Disabled, QPalette::WindowText), 0., Qt::DotLine); grid_pen = QPen(palette().color(QPalette::Disabled, QPalette::WindowText), 0., Qt::DotLine);
graphics.append(GraphicType()); graphics.append(GraphicType());
curGraphic = curTrace = 0; curGraphic = 0;
selpen = palette().color(QPalette::WindowText); selpen = palette().color(QPalette::WindowText);
selpen.setStyle(Qt::DashLine); selpen.setStyle(Qt::DashLine);
back_color = palette().color(QPalette::Base); back_color = palette().color(QPalette::Base);
@@ -206,7 +203,7 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
updateLegend(); updateLegend();
setRectToLines(); setRectToLines();
conf = new GraphicConf(graphics, this); 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) { if (e->timerId() == timer_pause) {
pause_phase += 0.02; pause_phase += 0.02;
if (pause_phase > 1.) pause_phase -= 1.; if (pause_phase > 1.) pause_phase -= 1.;
update(); repaintCanvas();
} }
if (e->timerId() == timer_record) { if (e->timerId() == timer_record) {
QPixmap im(canvas->size()); QPixmap im(canvas->size());
@@ -384,7 +381,7 @@ void Graphic::procZoom(QPointF view_center, double dzoom, Qt::KeyboardModifiers
void Graphic::totalUpdate() { void Graphic::totalUpdate() {
isFit = false; isFit = false;
emit visualRectChanged(); emit visualRectChanged();
update(true); repaintCanvas(true);
setRectToLines(); setRectToLines();
} }
@@ -479,11 +476,10 @@ void Graphic::canvasMouseMoveEvent(QMouseEvent * e) {
curpos = e->pos(); curpos = e->pos();
curpos_r = canvas2real(curpos); curpos_r = canvas2real(curpos);
QPointF dp; QPointF dp;
QString cursorstr = tr("Cursor: ") + pointCoords(curpos_r);
emit graphicMouseMoveEvent(curpos_r, e->buttons()); emit graphicMouseMoveEvent(curpos_r, e->buttons());
if (e->buttons() == Qt::NoButton) { if (e->buttons() == Qt::NoButton) {
ui->status->setText(cursorstr); if (ui->status->isVisible()) ui->status->setText(tr("Cursor: ") + pointCoords(curpos_r));
if (guides) update(); if (guides) repaintCanvas();
return; return;
} }
if (!navigation) return; if (!navigation) return;
@@ -494,18 +490,26 @@ void Graphic::canvasMouseMoveEvent(QMouseEvent * e) {
return; return;
switch (curaction) { switch (curaction) {
case gaZoomInRect: case gaZoomInRect:
ui->status->setText(tr("Selection") + ": " + pointCoords(startpos_r) + " -> " + pointCoords(curpos_r) + ", " + tr("Size") + ": " + if (ui->status->isVisible()) {
pointCoords(absPoint(curpos_r - startpos_r))); ui->status->setText(tr("Selection") + ": " + pointCoords(startpos_r) + " -> " + pointCoords(curpos_r) + ", " + tr("Size") +
": " + pointCoords(absPoint(curpos_r - startpos_r)));
}
repaintCanvas(true); repaintCanvas(true);
break; break;
case gaZoomRangeX: case gaZoomRangeX:
ui->status->setText(tr("Range") + ": " + QString::number(startpos_r.x(), 'f', 3) + " -> " + QString::number(curpos_r.x(), 'f', 3) + if (ui->status->isVisible()) {
", " + tr("Length") + ": " + QString::number(qAbs(curpos_r.x() - startpos_r.x()), 'f', 3)); 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); repaintCanvas(true);
break; break;
case gaZoomRangeY: case gaZoomRangeY:
ui->status->setText(tr("Range") + ": " + QString::number(startpos_r.y(), 'f', 3) + " -> " + QString::number(curpos_r.y(), 'f', 3) + if (ui->status->isVisible()) {
", " + tr("Length") + ": " + QString::number(qAbs(curpos_r.y() - startpos_r.y()), 'f', 3)); 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); repaintCanvas(true);
break; break;
case gaMove: case gaMove:
@@ -605,10 +609,11 @@ void Graphic::canvasMouseReleaseEvent(QMouseEvent * e) {
} }
} }
swapToNormal(); 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(); emit visualRectChanged();
} }
@@ -647,7 +652,7 @@ void Graphic::zoom(float factor) {
selrect.width() * factor, selrect.width() * factor,
selrect.height() * factor); selrect.height() * factor);
isFit = false; isFit = false;
update(true); repaintCanvas(true);
setRectToLines(); setRectToLines();
} }
@@ -662,8 +667,8 @@ void Graphic::fullscreen() {
void Graphic::canvasLeaveEvent(QEvent *) { void Graphic::canvasLeaveEvent(QEvent *) {
isHover = false; isHover = false;
if (guides) update(true); if (guides) repaintCanvas(true);
ui->status->setText(tr("Cursor") + ": ( ; )"); if (ui->status->isVisible()) ui->status->setText(tr("Cursor") + ": ( ; )");
leaveFullscreen(); leaveFullscreen();
} }
@@ -685,14 +690,19 @@ void Graphic::clear() {
graphics[i].max_x = 0.; graphics[i].max_x = 0.;
graphics[i].cvrect = QRectF(); graphics[i].cvrect = QRectF();
} }
if (isFit) on_graphic_buttonAutofit_clicked(); if (isFit) autofit();
} }
void Graphic::setAntialiasing(bool enabled) { void Graphic::setAntialiasing(bool enabled) {
if (aalias == enabled) return; if (aalias == enabled) return;
aalias = enabled; aalias = enabled;
update(); repaintCanvas();
}
void Graphic::setAutoUpdate(bool enabled) {
aupdate = enabled;
} }
@@ -706,7 +716,7 @@ void Graphic::setPaused(bool yes) {
if (!pause_) { if (!pause_) {
killTimer(timer_pause); killTimer(timer_pause);
timer_pause = 0; timer_pause = 0;
update(true); repaintCanvas(true);
return; return;
} }
for (int i = 0; i < graphics.size(); ++i) { for (int i = 0; i < graphics.size(); ++i) {
@@ -739,7 +749,57 @@ void Graphic::setHistorySize(double val) {
void Graphic::setMaxVisibleTime(double val) { void Graphic::setMaxVisibleTime(double val) {
visible_time = 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) { void Graphic::setGraphicsData(const Graphic::GraphicsData & gd) {
setGraphicsCount(gd.size()); setGraphicsCount(gd.size());
for (int i = 0; i < gd.size(); ++i) for (int i = 0; i < gd.size(); ++i) {
setGraphicData(gd[i], i, false); setGraphicData(gd[i], i, false);
}
updateGraphics(); 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) { void Graphic::setFloatingAxisEnabled(bool on) {
ui->graphic_checkGuides->setChecked(on); ui->graphic_checkGuides->setChecked(on);
} }
@@ -803,23 +920,24 @@ void Graphic::setFloatingAxisEnabled(bool on) {
void Graphic::setButtons(Graphic::Buttons b) { void Graphic::setButtons(Graphic::Buttons b) {
buttons_ = b; buttons_ = b;
ui->graphic_buttonAutofit->setVisible(b.testFlag(Autofit)); ui->graphic_buttonAutofit->setVisible(b.testFlag(Autofit));
ui->graphic_checkGrid->setVisible(b.testFlag(Grid));
ui->graphic_checkGuides->setVisible(b.testFlag(CursorAxis)); ui->graphic_checkGuides->setVisible(b.testFlag(CursorAxis));
ui->graphic_buttonFullscreen->setVisible(b.testFlag(Fullscreen)); ui->graphic_buttonFullscreen->setVisible(b.testFlag(Fullscreen));
ui->graphic_checkBorderInputs->setVisible(b.testFlag(BorderInputs)); ui->graphic_checkBorderInputs->setVisible(b.testFlag(BorderInputs));
ui->graphic_checkLegend->setVisible(b.testFlag(Legend)); ui->graphic_checkLegend->setVisible(b.testFlag(Legend));
ui->graphic_buttonClear->setVisible(b.testFlag(Clear)); ui->graphic_buttonClear->setVisible(b.testFlag(Clear));
ui->graphic_buttonConfigure->setVisible(b.testFlag(Configure)); ui->graphic_buttonConfigure->setVisible(b.testFlag(Configure));
ui->graphic_buttonSave->setVisible(b.testFlag(Save)); ui->graphic_buttonSaveMenu->setVisible(b.testFlag(Save) || b.testFlag(Export));
ui->graphic_buttonExport->setVisible(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_buttonClose->setVisible(b.testFlag(Close));
ui->graphic_checkPause->setVisible(b.testFlag(Pause)); ui->graphic_checkPause->setVisible(b.testFlag(Pause));
ui->graphic_buttonRecord->setVisible(b.testFlag(Record)); ui->graphic_buttonRecord->setVisible(b.testFlag(Record));
if (ui->graphic_buttonAutofit->isVisible() || ui->graphic_checkGrid->isVisible() || ui->graphic_checkGuides->isVisible() || if (ui->graphic_buttonAutofit->isVisible() || ui->graphic_checkGuides->isVisible() || ui->graphic_buttonConfigure->isVisible() ||
ui->graphic_buttonConfigure->isVisible() || ui->graphic_buttonSave->isVisible() || ui->graphic_checkPause->isVisible()) ui->graphic_checkPause->isVisible()) {
ui->verticalSpacer->changeSize(0, 30, QSizePolicy::Preferred, QSizePolicy::Preferred); ui->verticalSpacer->changeSize(0, 30, QSizePolicy::Preferred, QSizePolicy::Preferred);
else } else {
ui->verticalSpacer->changeSize(0, 0, QSizePolicy::Preferred, QSizePolicy::Preferred); ui->verticalSpacer->changeSize(0, 0, QSizePolicy::Preferred, QSizePolicy::Preferred);
}
ui->layoutButtons->update(); 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_) { void Graphic::addPoints(const QPolygonF & pts, int graphic, bool update_) {
if (graphic >= graphics.size() || graphic < 0 || pts.isEmpty()) return; if (graphic >= graphics.size() || graphic < 0 || pts.isEmpty()) return;
GraphicType & t(graphics[graphic]); 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(); 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(); if (t.max_x < p.x()) t.max_x = p.x();
}
t.polyline << pts; t.polyline << pts;
tick(graphic, true, update_); 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_) { void Graphic::addPoints(const QVector<double> & pts, int graphic, bool update_) {
QPolygonF ps; QPolygonF ps;
ps.reserve(pts.size()); ps.reserve(pts.size());
double stx = 0; double stx = 0;
if (!graphics[curGraphic].polyline.isEmpty()) stx = graphics[curGraphic].max_x; 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]); ps << QPointF(stx + i * inc_x, pts[i]);
}
addPoints(ps, graphic, update_); 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_) { void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic, bool update_) {
if (graphic >= graphics.size() || graphic < 0) return; if (graphic >= graphics.size() || graphic < 0) return;
GraphicType & t(graphics[graphic]); GraphicType & t(graphics[graphic]);
@@ -902,12 +1061,23 @@ void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic, bool updat
return; return;
} }
t.max_x = t.polyline[0].x(); t.max_x = t.polyline[0].x();
for (int i = 1; i < t.polyline.size(); ++i) for (const auto & p: t.polyline) {
if (t.max_x < t.polyline[i].x()) t.max_x = t.polyline[i].x(); if (t.max_x < p.x()) t.max_x = p.x();
}
tick(graphic, false, update_); 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, void Graphic::setGraphicProperties(int graphic,
const QString & name, const QString & name,
const QColor & color, 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) { 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(); updateLegend();
repaintCanvas();
} }
void Graphic::setVisualRect(const QRectF & rect) { void Graphic::setVisualRect(const QRectF & rect) {
selrect = rect; selrect = rect;
isFit = false; 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) { void Graphic::saveImage(QString filename) {
ppath = filename; ppath = filename;
QPixmap im(canvas->size()); QPixmap im(canvas->size());
canvas->render(&im); canvas->render(&im);
im.save(ppath); im.save(ppath);
update(true);
} }
@@ -1036,12 +1228,23 @@ void Graphic::setOpenGL(bool on) {
ui->canvas_raster->show(); ui->canvas_raster->show();
canvas = ui->canvas_raster; canvas = ui->canvas_raster;
#endif #endif
update(); repaintCanvas();
} }
void Graphic::update(bool force) { void Graphic::update() {
repaintCanvas(force); 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() { 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(); QPointF srp = -selrect.topLeft();
double sclx, scly, wid = canvas->width(), hei = canvas->height(); double sclx, scly, wid = canvas->width(), hei = canvas->height();
int cwid = (wid - gridborder.x() - margins_.left() - margins_.width()); int cwid = (wid - gridborder.x() - margins_.left() - margins_.width());
@@ -1606,33 +1811,6 @@ void Graphic::drawGuides() {
QString str; QString str;
str = pointCoords(rpos) + fp_size; str = pointCoords(rpos) + fp_size;
bool trace_found = false; 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) { auto trace_free_func = [&](QPointF cursor) {
double min_dist = -1; double min_dist = -1;
int gr = -1, mag_dist = fontHeight(this) * 2; int gr = -1, mag_dist = fontHeight(this) * 2;
@@ -1667,11 +1845,8 @@ void Graphic::drawGuides() {
emit graphicTraceEvent(gr, rpos); emit graphicTraceEvent(gr, rpos);
} }
}; };
switch (floating_axis_type) { if (floating_axis_type == Trace) {
case TraceXY: trace_free_func(rpos); break; trace_free_func(rpos);
case TraceX: trace_axis_func(true, rpos.x()); break;
case TraceY: trace_axis_func(false, rpos.y()); break;
default: break;
} }
if (was_trace && !trace_found) emit graphicTraceEvent(-1, QPointF()); if (was_trace && !trace_found) emit graphicTraceEvent(-1, QPointF());
was_trace = trace_found; was_trace = trace_found;
@@ -1823,49 +1998,70 @@ void Graphic::addDateTime(QDateTime & dt, int * c, qint64 mul) {
double Graphic::canvas2realX(double px) const { double Graphic::canvas2realX(double px) const {
int gbx = gridborder.x() + margins_.left(), cwid = lastw, wid = cwid - gbx - margins_.width(); int gbx = gridborder.x() + margins_.left();
double cx = px - gbx, sclx = selrect.width() / (double)wid; int wid = lastw - gbx - margins_.width();
double cx = px - gbx;
double sclx = selrect.width() / (double)wid;
return cx * sclx + selrect.x(); return cx * sclx + selrect.x();
} }
double Graphic::canvas2realY(double py) const { double Graphic::canvas2realY(double py) const {
int gby = gridborder.y() + margins_.top(), chei = lasth, hei = chei - gby - margins_.height(); int gby = gridborder.y() + margins_.top();
double cy = chei - py - gby, scly = selrect.height() / (double)hei; int hei = lasth - gby - margins_.height();
double cy = lasth - py - gby;
double scly = selrect.height() / (double)hei;
return cy * scly + selrect.y(); return cy * scly + selrect.y();
} }
double Graphic::real2canvasX(double px) const { 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; double sclx = selrect.width() / (double)wid;
return (px - selrect.x()) / sclx + gbx; return (px - selrect.x()) / sclx + gbx;
} }
double Graphic::real2canvasY(double py) const { 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; 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 Graphic::real2canvas(const QPolygonF & real_polygon) const {
QPolygonF ret; QPolygonF ret;
for (int i = 0; i < real_polygon.size(); ++i) for (const auto & p: real_polygon) {
ret << real2canvas(real_polygon[i]); ret << real2canvas(p);
}
return ret; return ret;
} }
QPolygonF Graphic::canvas2real(const QPolygonF & canvas_polygon) const { QPolygonF Graphic::canvas2real(const QPolygonF & canvas_polygon) const {
QPolygonF ret; QPolygonF ret;
for (int i = 0; i < canvas_polygon.size(); ++i) for (const auto & p: canvas_polygon) {
ret << canvas2real(canvas_polygon[i]); ret << canvas2real(p);
}
return ret; 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) { void Graphic::setCurrentAction(GraphicAction action) {
curaction = action; curaction = action;
switch (action) { switch (action) {
@@ -1939,10 +2135,10 @@ void Graphic::setRectToLines() {
else else
line_y_max.setValue(selrect.top()); line_y_max.setValue(selrect.top());
} }
line_x_min.setDefaultText(QString::number(grect.left()).toUpper()); // line_x_min.setDefaultText(QString::number(grect.left()).toUpper());
line_x_max.setDefaultText(QString::number(grect.right()).toUpper()); // line_x_max.setDefaultText(QString::number(grect.right()).toUpper());
line_y_min.setDefaultText(QString::number(grect.bottom()).toUpper()); // line_y_min.setDefaultText(QString::number(grect.bottom()).toUpper());
line_y_max.setDefaultText(QString::number(grect.top()).toUpper()); // line_y_max.setDefaultText(QString::number(grect.top()).toUpper());
line_x_min.blockSignals(false); line_x_min.blockSignals(false);
line_x_max.blockSignals(false); line_x_max.blockSignals(false);
line_y_min.blockSignals(false); line_y_min.blockSignals(false);
@@ -1954,7 +2150,7 @@ void Graphic::setRectToLines() {
void Graphic::checkLines() { void Graphic::checkLines() {
isFit = (line_x_min.isCleared() && line_x_max.isCleared() && line_y_min.isCleared() && line_y_max.isCleared()); 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 { } else {
calcLOD(index); calcLOD(index);
} }
if (!update_) {
if (isFit) findGraphicsRect(); if (isFit) findGraphicsRect();
return; if (aupdate && update_) repaintCanvas();
}
if (isFit) findGraphicsRect();
if (!slide) {
if (aupdate) update();
return;
}
if (aupdate) update();
} }
@@ -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() { void Graphic::on_graphic_buttonAutofit_clicked() {
isFit = true; autofit();
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();
} }
@@ -2074,6 +2257,7 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
conf->ui->checkInputs->setChecked(borderInputsVisible()); conf->ui->checkInputs->setChecked(borderInputsVisible());
conf->ui->checkStatus->setChecked(statusVisible()); conf->ui->checkStatus->setChecked(statusVisible());
conf->ui->checkLegend->setChecked(legendVisible()); conf->ui->checkLegend->setChecked(legendVisible());
conf->ui->groupGrid->setChecked(grid);
conf->ui->checkGridAutoX->setChecked(grad_x == Auto); conf->ui->checkGridAutoX->setChecked(grad_x == Auto);
conf->ui->checkGridAutoY->setChecked(grad_y == Auto); conf->ui->checkGridAutoY->setChecked(grad_y == Auto);
conf->ui->colorBackground->setColor(back_color); conf->ui->colorBackground->setColor(back_color);
@@ -2102,12 +2286,18 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
conf->ui->spinMarginR->value(), conf->ui->spinMarginR->value(),
conf->ui->spinMarginT->value(), conf->ui->spinMarginT->value(),
conf->ui->spinMarginB->value()); conf->ui->spinMarginB->value());
setGridEnabled(conf->ui->groupGrid->isChecked());
updateLegend(); 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, QString f = QFileDialog::getSaveFileName(this,
tr("Save Image"), tr("Save Image"),
ppath, 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)"); QString f = QFileDialog::getSaveFileName(this, tr("Export graphics"), ppath, "CSV(*.csv)");
if (f.isEmpty()) return; if (f.isEmpty()) return;
QStringList items; QStringList items;
@@ -2169,7 +2359,7 @@ void Graphic::on_graphic_buttonRecord_clicked(bool checked) {
void Graphic::on_graphic_checkGuides_toggled(bool checked) { void Graphic::on_graphic_checkGuides_toggled(bool checked) {
guides = checked; guides = checked;
setGuidesCursor(); setGuidesCursor();
update(); repaintCanvas();
} }
@@ -2231,15 +2421,6 @@ void Graphic::updateLegend(bool es) {
check->show(); check->show();
if (leg_sa->minimum_hei == 0) { if (leg_sa->minimum_hei == 0) {
leg_sa->minimum_hei = ui->widgetLegend->sizeHint().height(); 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++; col++;
if (col > maxcol) { if (col > maxcol) {
@@ -2250,7 +2431,6 @@ void Graphic::updateLegend(bool es) {
ui->gridLayout->invalidate(); ui->gridLayout->invalidate();
ui->scrollLegend->setVisible(lv); ui->scrollLegend->setVisible(lv);
leg_sa->updateGeometry(); leg_sa->updateGeometry();
// ui->gridLayout->invalidate();
leg_update = true; leg_update = true;
if (es) emit graphicSettingsChanged(); if (es) emit graphicSettingsChanged();
} }
@@ -2273,9 +2453,9 @@ void Graphic::graphicVisibleChange(bool checked) {
int i = cb->property("graphic_num").toInt(); int i = cb->property("graphic_num").toInt();
graphics[i].visible = checked; graphics[i].visible = checked;
if (isFit) if (isFit)
on_graphic_buttonAutofit_clicked(); autofit();
else { else {
update(); repaintCanvas();
} }
emit graphicSettingsChanged(); emit graphicSettingsChanged();
} }
@@ -2289,14 +2469,49 @@ void Graphic::graphicAllVisibleChange(bool checked) {
} }
visible_update = false; visible_update = false;
if (isFit) if (isFit)
on_graphic_buttonAutofit_clicked(); autofit();
else { else {
update(); repaintCanvas();
} }
emit graphicSettingsChanged(); 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() { void Graphic::enterFullscreen() {
if (fullscr) return; if (fullscr) return;
fullscr = true; fullscr = true;
@@ -2398,6 +2613,7 @@ QByteArray Graphic::save() {
if (backgroundColor() == palette().color(QPalette::Base) && textColor() == palette().color(QPalette::WindowText) && if (backgroundColor() == palette().color(QPalette::Base) && textColor() == palette().color(QPalette::WindowText) &&
gridColor() == palette().color(QPalette::Disabled, QPalette::WindowText)) gridColor() == palette().color(QPalette::Disabled, QPalette::WindowText))
cs.add(17, true); cs.add(17, true);
cs.add(18, gridEnabled());
return cs.data().prepend('2'); return cs.data().prepend('2');
} }
@@ -2405,6 +2621,7 @@ QByteArray Graphic::save() {
void Graphic::load(QByteArray ba) { void Graphic::load(QByteArray ba) {
if (ba.isEmpty()) return; if (ba.isEmpty()) return;
char ver = ba[0]; char ver = ba[0];
bool has_opengl = isOGL;
switch (ver) { switch (ver) {
case '2': { // version '2': case '2': { // version '2':
ba.remove(0, 1); ba.remove(0, 1);
@@ -2413,36 +2630,37 @@ void Graphic::load(QByteArray ba) {
bool def_colors = false; bool def_colors = false;
while (!cs.atEnd()) { while (!cs.atEnd()) {
switch (cs.read()) { switch (cs.read()) {
case 1: setAntialiasing(cs.getData<bool>()); break; case 1: aalias = cs.getData<bool>(); break;
case 2: setOpenGL(cs.getData<bool>()); break; case 2: has_opengl = cs.getData<bool>(); break;
case 3: setBorderInputsVisible(cs.getData<bool>()); break; case 3: setBorderInputsVisible(cs.getData<bool>()); break;
case 4: setStatusVisible(cs.getData<bool>()); break; case 4: setStatusVisible(cs.getData<bool>()); break;
case 5: setLegendVisible(cs.getData<bool>()); break; case 5: setLegendVisible(cs.getData<bool>()); break;
case 6: case 6:
if (!def_colors) setBackgroundColor(cs.getData<QColor>()); if (!def_colors) back_color = cs.getData<QColor>();
break; break;
case 7: case 7:
if (!def_colors) setTextColor(cs.getData<QColor>()); if (!def_colors) text_color = cs.getData<QColor>();
break; break;
case 8: setMargins(cs.getData<QRect>()); break; case 8: margins_ = cs.getData<QRect>(); break;
case 9: case 9:
if (!def_colors) setGridPen(cs.getData<QPen>()); if (!def_colors) grid_pen = cs.getData<QPen>();
break; break;
case 10: setGraduationX(cs.getData<Graduation>()); break; case 10: grad_x = cs.getData<Graduation>(); break;
case 11: setGraduationY(cs.getData<Graduation>()); break; case 11: grad_y = cs.getData<Graduation>(); break;
case 12: setGraduationStepX(cs.getData<double>()); break; case 12: gridx = cs.getData<double>(); break;
case 13: setGraduationStepY(cs.getData<double>()); break; case 13: gridy = cs.getData<double>(); break;
case 14: graphics = cs.getData<QVector<GraphicType>>(); break; case 14: graphics = cs.getData<QVector<GraphicType>>(); break;
case 15: isFit = cs.getData<bool>(); break; case 15: isFit = cs.getData<bool>(); break;
case 16: vrect = cs.getData<QRectF>(); break; case 16: vrect = cs.getData<QRectF>(); break;
case 17: case 17:
if (cs.getData<bool>()) { if (cs.getData<bool>()) {
setTextColor(palette().color(QPalette::WindowText)); text_color = palette().color(QPalette::WindowText);
setGridPen(QPen(palette().color(QPalette::Disabled, QPalette::WindowText), 0., Qt::DotLine)); grid_pen = QPen(palette().color(QPalette::Disabled, QPalette::WindowText), 0., Qt::DotLine);
setBackgroundColor(palette().color(QPalette::Base)); back_color = palette().color(QPalette::Base);
def_colors = true; def_colors = true;
} }
break; break;
case 18: grid = cs.getData<bool>(); break;
default: break; default: break;
} }
} }
@@ -2451,10 +2669,8 @@ void Graphic::load(QByteArray ba) {
default: { // old version 0: default: { // old version 0:
QDataStream s(ba); QDataStream s(ba);
bool a; bool a;
s >> a; s >> has_opengl;
setOpenGL(a); s >> aalias;
s >> a;
setAntialiasing(a);
s >> a; s >> a;
setBorderInputsVisible(a); setBorderInputsVisible(a);
s >> a; s >> a;
@@ -2464,28 +2680,253 @@ void Graphic::load(QByteArray ba) {
setLegendVisible(a); setLegendVisible(a);
} break; } 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) { void Graphic::setCaption(const QString & str) {
ui->labelCaption->setText(str); ui->labelCaption->setText(str);
ui->labelCaption->setVisible(str.length() > 0); 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) { void Graphic::setGraphicVisible(bool visible, int index) {
graphics[index].visible = visible; graphics[index].visible = visible;
updateLegendChecks(); updateLegendChecks();
if (isFit) if (isFit) {
on_graphic_buttonAutofit_clicked(); autofit();
else if (aupdate) } else if (aupdate) {
update(); 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) { 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) { void Graphic::actionGuidesTriggered(QAction * a) {
ui->graphic_checkGuides->setChecked(true); ui->graphic_checkGuides->setChecked(true);
setFloatingAxisType((FloatingAxisType)a->property("_value").toInt()); setFloatingAxisType((FloatingAxisType)a->property("_value").toInt());

View File

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

View File

@@ -68,23 +68,6 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<widget class="QToolButton" name="graphic_checkGuides"> <widget class="QToolButton" name="graphic_checkGuides">
<property name="toolTip"> <property name="toolTip">
@@ -167,7 +150,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="graphic_buttonSave"> <widget class="QToolButton" name="graphic_buttonSaveMenu">
<property name="toolTip"> <property name="toolTip">
<string>Save image ...</string> <string>Save image ...</string>
</property> </property>
@@ -175,16 +158,8 @@
<iconset resource="../blockview/qad_blockview.qrc"> <iconset resource="../blockview/qad_blockview.qrc">
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset> <normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
</property> </property>
</widget> <property name="popupMode">
</item> <enum>QToolButton::InstantPopup</enum>
<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> </property>
</widget> </widget>
</item> </item>
@@ -442,22 +417,6 @@
<string>Free</string> <string>Free</string>
</property> </property>
</action> </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"> <action name="graphic_actionExpandX">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@@ -488,6 +447,24 @@
<string>Snap trace</string> <string>Snap trace</string>
</property> </property>
</action> </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> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
@@ -500,9 +477,6 @@
<include location="../application/qad_application.qrc"/> <include location="../application/qad_application.qrc"/>
<include location="../blockview/qad_blockview.qrc"/> <include location="../blockview/qad_blockview.qrc"/>
<include location="qad_graphic.qrc"/> <include location="qad_graphic.qrc"/>
<include location="../application/qad_application.qrc"/>
<include location="../blockview/qad_blockview.qrc"/>
<include location="qad_graphic.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

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

View File

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

View File

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

View File

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