version 2.20
icon change EDockWidget improvements EMainWindow small refactoring Graphic now remember last loaded graphics style and restore it on setGraphicsCount
This commit is contained in:
@@ -1252,24 +1252,31 @@ void Graphic::setCurrentGraphic(int arg) {
|
||||
}
|
||||
|
||||
|
||||
void Graphic::setGraphicsCount(int arg, bool update) {
|
||||
if (arg < 0) return;
|
||||
while (graphics.size() < arg) {
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
graphics.append(
|
||||
GraphicType(tr("y(x)"),
|
||||
QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - QRandomGenerator::global()->generate() % 115)));
|
||||
# define _G_QRAND_ QRandomGenerator::global()->generate()
|
||||
#else
|
||||
graphics.append(GraphicType(tr("y(x)"), QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - qrand() % 115)));
|
||||
# define _G_QRAND_ qrand()
|
||||
#endif
|
||||
|
||||
void Graphic::setGraphicsCount(int count, bool update) {
|
||||
if (count < 0) return;
|
||||
while (graphics.size() < count) {
|
||||
GraphicType gt(tr("y(x)"));
|
||||
if (loaded_configs.size() > graphics.size())
|
||||
gt = loaded_configs[graphics.size()];
|
||||
else
|
||||
gt.pen.setColor(QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - _G_QRAND_ % 115));
|
||||
graphics.append(gt);
|
||||
}
|
||||
while (graphics.size() > arg) {
|
||||
while (graphics.size() > count) {
|
||||
delete graphics.back().pb;
|
||||
graphics.pop_back();
|
||||
}
|
||||
if (update) updateLegend();
|
||||
}
|
||||
|
||||
#undef _G_QRAND_
|
||||
|
||||
|
||||
void Graphic::removeGraphic(int arg, bool update) {
|
||||
if (arg < 0 || arg >= graphics.size()) return;
|
||||
@@ -2309,6 +2316,10 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
|
||||
setGridEnabled(conf->ui->groupGrid->isChecked());
|
||||
updateLegend();
|
||||
repaintCanvas();
|
||||
for (int i = 0; i < qMin<int>(graphics.size(), loaded_configs.size()); ++i) {
|
||||
loaded_configs[i] = graphics[i];
|
||||
loaded_configs[i].removeData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2702,6 +2713,9 @@ void Graphic::load(QByteArray ba) {
|
||||
setLegendVisible(a);
|
||||
} break;
|
||||
}
|
||||
loaded_configs = graphics;
|
||||
for (auto & i: loaded_configs)
|
||||
i.removeData();
|
||||
if (has_opengl != isOGL) setOpenGL(has_opengl);
|
||||
updateLegend();
|
||||
repaintCanvas(true);
|
||||
|
||||
@@ -442,7 +442,7 @@ protected:
|
||||
QBrush selbrush;
|
||||
QPen grid_pen, selpen;
|
||||
QColor back_color, text_color;
|
||||
QVector<GraphicType> graphics;
|
||||
QVector<GraphicType> graphics, loaded_configs;
|
||||
int curGraphic;
|
||||
GraphicAction curaction, prevaction;
|
||||
QRectF grect, selrect, limit_, def_rect;
|
||||
|
||||
@@ -3,6 +3,38 @@
|
||||
#include "qad_types.h"
|
||||
#include "ui_graphic_conf.h"
|
||||
|
||||
// GraphicType
|
||||
|
||||
GraphicType::GraphicType(QString name_, QColor color, Qt::PenStyle style, double width, bool visible_) {
|
||||
pen.setColor(color);
|
||||
pen.setStyle(style);
|
||||
lines = true;
|
||||
points = false;
|
||||
fill = false;
|
||||
fill_color = Qt::yellow;
|
||||
if (qRound(width) == width)
|
||||
pen.setWidth(qRound(width));
|
||||
else
|
||||
pen.setWidthF(width);
|
||||
pen.setWidth(1);
|
||||
pen.setCosmetic(true);
|
||||
max_x = 0.;
|
||||
name = name_;
|
||||
visible = visible_;
|
||||
pointWidth = 2.;
|
||||
pb = new QCheckBox(name);
|
||||
}
|
||||
|
||||
|
||||
void GraphicType::removeData() {
|
||||
polyline.clear();
|
||||
polyline_pause.clear();
|
||||
_lod.clear();
|
||||
_lod_pause.clear();
|
||||
}
|
||||
|
||||
|
||||
// GraphicConf
|
||||
|
||||
GraphicConf::GraphicConf(QVector<GraphicType> & graphics_, QWidget * parent): QDialog(parent), graphics(graphics_) {
|
||||
ui = new Ui::GraphicConf();
|
||||
|
||||
@@ -35,28 +35,11 @@ class GraphicConf;
|
||||
|
||||
struct QAD_GRAPHIC_EXPORT GraphicType {
|
||||
GraphicType(QString name_ = "y(x)",
|
||||
QColor color = Qt::red,
|
||||
Qt::PenStyle style = Qt::SolidLine,
|
||||
double width = 0.,
|
||||
bool visible_ = true) {
|
||||
pen.setColor(color);
|
||||
pen.setStyle(style);
|
||||
lines = true;
|
||||
points = false;
|
||||
fill = false;
|
||||
fill_color = Qt::yellow;
|
||||
if (qRound(width) == width)
|
||||
pen.setWidth(qRound(width));
|
||||
else
|
||||
pen.setWidthF(width);
|
||||
pen.setWidth(1);
|
||||
pen.setCosmetic(true);
|
||||
max_x = 0.;
|
||||
name = name_;
|
||||
visible = visible_;
|
||||
pointWidth = 2.;
|
||||
pb = new QCheckBox(name);
|
||||
}
|
||||
QColor color = Qt::red,
|
||||
Qt::PenStyle style = Qt::SolidLine,
|
||||
double width = 0.,
|
||||
bool visible_ = true);
|
||||
void removeData();
|
||||
//~GraphicType() {delete pb;}
|
||||
QString name;
|
||||
QPolygonF polyline;
|
||||
|
||||
Reference in New Issue
Block a user