diff --git a/CMakeLists.txt b/CMakeLists.txt index 8308f8e..f6fc684 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default project(QAD) set(QAD_MAJOR 2) -set(QAD_MINOR 23) +set(QAD_MINOR 24) set(QAD_REVISION 0) set(QAD_SUFFIX ) set(QAD_COMPANY SHS) diff --git a/libs/graphic/graphic.cpp b/libs/graphic/graphic.cpp index 5982cd3..bba9dbb 100644 --- a/libs/graphic/graphic.cpp +++ b/libs/graphic/graphic.cpp @@ -1133,8 +1133,24 @@ void Graphic::autofit() { void Graphic::saveImage(QString filename) { ppath = filename; - QPixmap im(canvas->size()); - canvas->render(&im); + QPixmap im; + QString custom_title; + if (func_image_title) custom_title = func_image_title(); + if (custom_title.isEmpty()) { + im = QPixmap(canvas->size()); + canvas->render(&im); + } else { + QSize sz = canvas->size(); + QRectF tbr = fontMetrics().boundingRect(QRect(0, 0, sz.width(), 1), Qt::TextWordWrap, custom_title); + sz.setHeight(sz.height() + tbr.height()); + im = QPixmap(canvas->size()); + im.fill(back_color); + QPainter p(&im); + p.setPen(text_color); + p.drawText(tbr, Qt::TextWordWrap, custom_title); + p.end(); + canvas->render(&im, QPoint(0, tbr.height())); + } im.save(ppath); } @@ -1300,6 +1316,11 @@ void Graphic::setCustomGridMarkFuncs(std::function fx, std::fun } +void Graphic::setCustomSaveImageTitleFunc(std::function func) { + func_image_title = func; +} + + 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); diff --git a/libs/graphic/graphic.h b/libs/graphic/graphic.h index c293904..166bd2d 100644 --- a/libs/graphic/graphic.h +++ b/libs/graphic/graphic.h @@ -380,6 +380,7 @@ public slots: void setGraphicsCount(int arg, bool update = true); void removeGraphic(int arg, bool update = true); void setCustomGridMarkFuncs(std::function fx, std::function fy); + void setCustomSaveImageTitleFunc(std::function func); void zoom(float factor); void zoomIn() { zoom(1. / 1.2); } @@ -475,6 +476,7 @@ protected: 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; + std::function func_image_title; QVector date_formats; QList record_imgs;