diff --git a/CMakeLists.txt b/CMakeLists.txt index d0bd9ec..48f7797 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,8 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default project(qad) set(qad_MAJOR 2) -set(qad_MINOR 6) -set(qad_REVISION 1) +set(qad_MINOR 7) +set(qad_REVISION 0) set(qad_SUFFIX ) set(qad_COMPANY SHS) set(qad_DOMAIN org.SHS) diff --git a/libs/graphic/graphic.cpp b/libs/graphic/graphic.cpp index 7835705..1b0c82c 100644 --- a/libs/graphic/graphic.cpp +++ b/libs/graphic/graphic.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) # include #endif @@ -72,6 +73,7 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this), #else false; #endif + func_gridMarkX = func_gridMarkY = nullptr; ui = new Ui::Graphic(); ui->setupUi(this); ui->scrollLegend->layout()->addWidget(new LegendScrollArea(ui->widgetLegend)); @@ -189,6 +191,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())); } @@ -916,7 +919,7 @@ void Graphic::saveImage(QString filename) { } -void Graphic::exportGraphics(QString filename) { +void Graphic::exportGraphics(QString filename, QChar decimal_point) { ppath = filename; QFile f(filename); if (!f.open(QIODevice::ReadWrite)) { @@ -930,7 +933,7 @@ void Graphic::exportGraphics(QString filename) { for (int i = 0; i < graphics.size(); ++i) { GraphicType & g(graphics[i]); if (!g.visible) continue; - ts << ";" << (g.name + "_X") << ";" << (g.name + "_Y"); + ts << ";" << (g.name + " " + (label_x.isEmpty() ? "X" : label_x)) << ";" << (g.name + " " + (label_y.isEmpty() ? "Y" : label_y)); } ts << "\n"; bool has_data = true; @@ -949,9 +952,9 @@ void Graphic::exportGraphics(QString filename) { } has_data = true; line += ";"; - line += QString::number(g.polyline[ind].x(), 'g', 9); + line += QString::number(g.polyline[ind].x(), 'g', 9).replace('.', decimal_point); line += ";"; - line += QString::number(g.polyline[ind].y(), 'g', 9); + line += QString::number(g.polyline[ind].y(), 'g', 9).replace('.', decimal_point); } ++ind; line += "\n"; @@ -1028,6 +1031,12 @@ void Graphic::removeGraphic(int arg, bool update) { } +void Graphic::setCustomGridMarkFuncs(std::function fx, std::function fy) { + func_gridMarkX = fx; + func_gridMarkY = fy; +} + + void Graphic::findGraphicsRect(double start_x, double end_x, double start_y, double end_y) { double cx, cy, maxX, minX, maxY, minY, vx; bool isRangeX = (start_x != end_x), isRangeY = (start_y != end_y); @@ -1174,15 +1183,20 @@ void Graphic::drawGrid() { if (cy > hei + 5) break; painter->setPen(grid_pen); painter->drawLine(gbx, cy, cwid, cy); - str = gridMark(py * grid_numbers_y); painter->setPen(text_color); cy += font_sz.height() / 4.; int dx = font_sz.height() / 8.; - if (!str.second.isEmpty()) { - rect = sfm.boundingRect(str.second); - painter->setFont(sf); - painter->drawText(cx - rect.width() - dx, cy - font_sz.height() / 2.5, str.second); - dx += rect.width() + font_sz.height() / 6.; + if (func_gridMarkY) { + str.first = func_gridMarkY(py * grid_numbers_y); + str.second.clear(); + } else { + str = gridMark(py * grid_numbers_y); + if (!str.second.isEmpty()) { + rect = sfm.boundingRect(str.second); + painter->setFont(sf); + painter->drawText(cx - rect.width() - dx, cy - font_sz.height() / 2.5, str.second); + dx += rect.width() + font_sz.height() / 6.; + } } rect = fm.boundingRect(str.first); painter->setFont(nf); @@ -1227,11 +1241,16 @@ void Graphic::drawGrid() { painter->setPen(text_color); int dx = -font_sz.height() / 4.; painter->setFont(nf); - str = gridMark(px * grid_numbers_x); + if (func_gridMarkX) { + str.first = func_gridMarkX(px * grid_numbers_x); + str.second.clear(); + } else { + str = gridMark(px * grid_numbers_x); + } rect = fm.boundingRect(str.first); painter->drawText(cx + dx, cy, str.first); - dx += rect.width() + font_sz.height() / 6.; if (!str.second.isEmpty()) { + dx += rect.width() + font_sz.height() / 6.; rect = sfm.boundingRect(str.second); painter->setFont(sf); painter->drawText(cx + dx, cy - font_sz.height() / 4., str.second); @@ -1886,7 +1905,11 @@ void Graphic::on_graphic_buttonSave_clicked() { void Graphic::on_graphic_buttonExport_clicked() { QString f = QFileDialog::getSaveFileName(this, tr("Export graphics"), ppath, "CSV(*.csv)"); if (f.isEmpty()) return; - exportGraphics(f); + QStringList items; + items << "." << ","; + bool ok; + QString item = QInputDialog::getItem(this, tr("Select decimal point"), tr("Decimal point:"), items, 0, false, &ok); + if (ok && !item.isEmpty()) exportGraphics(f, item.front()); } diff --git a/libs/graphic/graphic.h b/libs/graphic/graphic.h index 61d834c..69b35dc 100644 --- a/libs/graphic/graphic.h +++ b/libs/graphic/graphic.h @@ -339,7 +339,7 @@ public slots: void setDefaultRect(const QRectF & rect); void autofit() {on_graphic_buttonAutofit_clicked();} void saveImage(QString filename); - void exportGraphics(QString filename); + void exportGraphics(QString filename, QChar decimal_point); void clear(); void update(bool force); void update() {update(false);} @@ -348,6 +348,7 @@ public slots: void setTraceGraphic(int arg) {if (arg < 0 || arg >= graphics.size()) return; curTrace = arg;} void setGraphicsCount(int arg, bool update = true); void removeGraphic(int arg, bool update = true); + void setCustomGridMarkFuncs(std::function fx, std::function fy); void zoom(float factor); void zoomIn() {zoom(1. / 1.2);} @@ -430,6 +431,7 @@ protected: int lastw, lasth, min_repaint_int, timer_pause, thick; bool aalias, aupdate, grid, guides, isFit, isOGL, isHover, bufferActive, cancel, pause_, gestures, m_LODOptimization, m_fakeGL, need_createGL; bool hasLblX, hasLblY, navigation, only_expand_y, only_expand_x, is_lines_update, leg_update, visible_update, fullscr, need_mouse_pan, was_trace; + std::function func_gridMarkX, func_gridMarkY; protected slots: void canvasPaintEvent(); diff --git a/libs/graphic/graphic_conf.cpp b/libs/graphic/graphic_conf.cpp index 231b192..e0c94fb 100644 --- a/libs/graphic/graphic_conf.cpp +++ b/libs/graphic/graphic_conf.cpp @@ -101,6 +101,11 @@ void GraphicConf::on_checkFill_toggled(bool on) { } +void GraphicConf::on_buttonExport_clicked() { + emit exportClicked(); +} + + void GraphicConf::on_colorFill_colorChanged(const QColor & color) { if (graphicItems.isEmpty()) return; graphics[ui->cbGraphicNames->currentIndex()].fill_color = color; diff --git a/libs/graphic/graphic_conf.h b/libs/graphic/graphic_conf.h index 0ad78d9..1146eb3 100644 --- a/libs/graphic/graphic_conf.h +++ b/libs/graphic/graphic_conf.h @@ -108,7 +108,10 @@ private slots: void on_checkLines_toggled(bool on); void on_checkPoints_toggled(bool on); void on_checkFill_toggled(bool on); + void on_buttonExport_clicked(); +signals: + void exportClicked(); }; #endif // GRAPHIC_CONF_H diff --git a/libs/graphic/graphic_conf.ui b/libs/graphic/graphic_conf.ui index fc60581..edc28ec 100644 --- a/libs/graphic/graphic_conf.ui +++ b/libs/graphic/graphic_conf.ui @@ -9,8 +9,8 @@ 0 0 - 500 - 583 + 387 + 505 @@ -19,8 +19,8 @@ true - - + + Appearance @@ -115,248 +115,15 @@ - - - - Graphics - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - - 0 - 0 - - - - - - - - Color: - - - - - - - true - - - - - - - Style: - - - - - - - - - - Lines width: - - - true - - - - - - - 2 - - - 1.000000000000000 - - - - - - - Points width: - - - true - - - - - - - 2 - - - 999.990000000000009 - - - 1.000000000000000 - - - - - - - Fill: - - - true - - - - - - - true - - - - - - - - - - Grid - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Color: - - - - - - - true - - - - - - - Style: - - - - - - - - - - Width: - - - - - - - 2 - - - - - - - Step X: - - - - - - - Step Y: - - - - - - - Auto X - - - true - - - - - - - Auto Y - - - true - - - - - - - 30 - - - 30 - - - true - - - - - - - 50 - - - 50 - - - true - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + Margins - + + + 0 + @@ -460,6 +227,261 @@ + + + + + + Grid + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Color: + + + + + + + true + + + + + + + Style: + + + + + + + + + + Width: + + + + + + + 2 + + + + + + + Step X: + + + + + + + Step Y: + + + + + + + Auto X + + + true + + + + + + + Auto Y + + + true + + + + + + + 30 + + + 30 + + + true + + + + + + + 50 + + + 50 + + + true + + + + + + + + + + Graphics + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + + 0 + 0 + + + + + + + + Color: + + + + + + + true + + + + + + + Style: + + + + + + + + + + Lines width: + + + true + + + + + + + 2 + + + 1.000000000000000 + + + + + + + Points width: + + + true + + + + + + + 2 + + + 999.990000000000009 + + + 1.000000000000000 + + + + + + + Fill: + + + true + + + + + + + true + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Export to CSV... + + + + :/icons/accessories-text-editor.png:/icons/accessories-text-editor.png + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + @@ -494,7 +516,10 @@ spinPointWidthGraphic buttonBox - + + + + buttonBox diff --git a/libs/graphic/lang/qad_graphic_en.ts b/libs/graphic/lang/qad_graphic_en.ts index 656e107..67a1532 100644 --- a/libs/graphic/lang/qad_graphic_en.ts +++ b/libs/graphic/lang/qad_graphic_en.ts @@ -101,63 +101,73 @@ - - + + Cursor: - + Selection - + Size - - + + Range - - + + Length - - + + Cursor - - + + Export graphics - + Can`t open file "%1"! - + Save Image - - + + y(x) - + + Select decimal point + + + + + Decimal point: + + + + Check all @@ -210,115 +220,120 @@ - + Graphics - - + + Export to CSV... + + + + + Color: - - + + Style: - + Lines width: - + Points width: - + Fill: - + Grid - + Width: - + Step X: - + Step Y: - + Auto X - + Auto Y - - + + 30 - - + + 50 - + Margins - - - - - + + + + + px - + All: - + Right: - + Left: - + Bottom: - + Top: diff --git a/libs/graphic/lang/qad_graphic_ru.ts b/libs/graphic/lang/qad_graphic_ru.ts index 4e6d377..ffa3d80 100644 --- a/libs/graphic/lang/qad_graphic_ru.ts +++ b/libs/graphic/lang/qad_graphic_ru.ts @@ -105,63 +105,73 @@ Свободная трассировка - - + + Cursor: Курсор: - + Selection Выделение - + Size Размер - - + + Range Диапазон - - + + Length Длина - - + + Cursor Курсор - - + + Export graphics Экспорт графиков - + Can`t open file "%1"! Невозможно открыть файл "%1"! - + Save Image Сохранить изображение - - + + y(x) - + + Select decimal point + Выберите десятичный разделитель + + + + Decimal point: + Десятичный разделитель: + + + Check all Выбрать все @@ -214,76 +224,81 @@ Цвет текста: - + Graphics Графики - - + + Export to CSV... + Экспорт в CSV... + + + + Color: Цвет: - - + + Style: Стиль: - + Lines width: Толщина линий: - + Points width: Толщина точек: - + Fill: Заливка: - + Grid Сетка - + Width: Толщина: - + Step X: Шаг X: - + Step Y: Шаг Y: - + Auto X Авто X - + Auto Y Авто Y - - + + 30 - - + + 50 @@ -292,41 +307,41 @@ Автоматический шаг - + Margins Поля - - - - - + + + + + px пикс - + All: Все: - + Right: Правое: - + Left: Левое: - + Bottom: Нижнее: - + Top: Верхнее: