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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user