From c144c149e67aa23a8c16d6813e74a6dc7d0567b5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 11 Apr 2015 14:01:25 +0300 Subject: [PATCH 1/5] Class VPoster. --HG-- branch : feature --- src/app/core/vapplication.h | 2 +- src/app/options.h | 1 + src/libs/ifc/exception/vexception.cpp | 1 + src/libs/ifc/ifcdef.h | 58 ----- src/libs/vlayout/share/icons.qrc | 6 + .../vlayout/share/scissors_horizontal.png | Bin 0 -> 696 bytes src/libs/vlayout/share/scissors_vertical.png | Bin 0 -> 726 bytes src/libs/vlayout/vlayout.pri | 6 +- src/libs/vlayout/vlayout.pro | 5 +- src/libs/vlayout/vposter.cpp | 239 ++++++++++++++++++ src/libs/vlayout/vposter.h | 60 +++++ src/utils/def.h | 92 +++++++ src/utils/utils.pri | 3 +- 13 files changed, 410 insertions(+), 63 deletions(-) create mode 100644 src/libs/vlayout/share/icons.qrc create mode 100644 src/libs/vlayout/share/scissors_horizontal.png create mode 100644 src/libs/vlayout/share/scissors_vertical.png create mode 100644 src/libs/vlayout/vposter.cpp create mode 100644 src/libs/vlayout/vposter.h create mode 100644 src/utils/def.h diff --git a/src/app/core/vapplication.h b/src/app/core/vapplication.h index e7f074944..da5df856d 100644 --- a/src/app/core/vapplication.h +++ b/src/app/core/vapplication.h @@ -279,7 +279,7 @@ inline void VApplication::setCurrentDocument(VPattern *doc) inline VPattern *VApplication::getCurrentDocument() const { SCASSERT(doc != nullptr) - return doc; + return doc; } #endif // VAPPLICATION_H diff --git a/src/app/options.h b/src/app/options.h index 57380992a..9ea81af9c 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -30,6 +30,7 @@ #define OPTIONS_H #include "../libs/ifc/ifcdef.h" +#include "../../utils/def.h" #ifdef Q_OS_WIN32 # if defined( Q_CC_MSVC ) // MSVC USED diff --git a/src/libs/ifc/exception/vexception.cpp b/src/libs/ifc/exception/vexception.cpp index 94dab8cfe..e1da1d3e1 100644 --- a/src/libs/ifc/exception/vexception.cpp +++ b/src/libs/ifc/exception/vexception.cpp @@ -28,6 +28,7 @@ #include "vexception.h" #include "../../../utils/logging.h" +#include "../../../utils/def.h" #include #include diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index a3d98ad03..506533397 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -29,7 +29,6 @@ #ifndef IFCDEF_H #define IFCDEF_H -#include #include #ifdef Q_OS_WIN32 @@ -45,63 +44,6 @@ static const quint32 null_id = 0; #define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value. #define NULL_ID_STR "0" -/* - * This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow - * you to continue afterwards should you choose to. - * idea: Q_ASSERT no longer pauses debugger - http://qt-project.org/forums/viewthread/13148 - * Usefull links: - * 1. What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__? - - * https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func - * - * 2. Windows Predefined Macros - http://msdn.microsoft.com/library/b0084kay.aspx - * - * 3. Windows DebugBreak function - http://msdn.microsoft.com/en-us/library/ms679297%28VS.85%29.aspx - * - * 4. Continue to debug after failed assertion on Linux? [C/C++] - - * https://stackoverflow.com/questions/1721543/continue-to-debug-after-failed-assertion-on-linux-c-c - */ -#ifndef V_NO_ASSERT -#ifdef Q_OS_WIN32 -#ifdef Q_CC_MSVC -#define SCASSERT(cond) \ -{ \ - if (!(cond)) \ - { \ - qDebug("ASSERT: %s in %s (%s:%u)", \ - #cond, __FUNCSIG__, __FILE__, __LINE__); \ - DebugBreak(); \ - } \ -} \ - -#else // GCC (Windows) - -#define SCASSERT(cond) \ -{ \ - if (!(cond)) \ - { \ - qDebug("ASSERT: %s in %s (%s:%u)", \ - #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ - DebugBreak(); \ - } \ -} \ - -#endif /*Q_CC_MSVC*/ -#else // UNIX -#define SCASSERT(cond) \ -{ \ - if (!(cond)) \ - { \ - qDebug("ASSERT: %s in %s (%s:%u)", \ - #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ - std::raise(SIGTRAP); \ - } \ -} \ - -#endif /* Q_OS_WIN32 */ -#else // define but disable this function if debugging is not set -#define SCASSERT(cond) qt_noop(); -#endif /* V_NO_ASSERT */ - // Detect whether the compiler supports C++11 noexcept exception specifications. # if defined(__clang__) # if __has_feature(cxx_noexcept) diff --git a/src/libs/vlayout/share/icons.qrc b/src/libs/vlayout/share/icons.qrc new file mode 100644 index 000000000..daa859f6f --- /dev/null +++ b/src/libs/vlayout/share/icons.qrc @@ -0,0 +1,6 @@ + + + scissors_horizontal.png + scissors_vertical.png + + diff --git a/src/libs/vlayout/share/scissors_horizontal.png b/src/libs/vlayout/share/scissors_horizontal.png new file mode 100644 index 0000000000000000000000000000000000000000..3f732e4ce5f7065c1878eb6541df281679369327 GIT binary patch literal 696 zcmV;p0!RIcP))9Kyt;qCU5-%_t}NjhP3*fK6ygu%EH512%K84ol0_;9o@zHiv-%E@PVi44b050jLDcv%{5aesS+T^La<=A_P6VlkfL8XjOs z-qHbi6+Tsiwb{6xcXVyh`U2bxiyNwy(&hQDox#A8y{)Oa6KVRtp|%Txdz+Rr3FAxl zT9VFQ<^F)|Nb(CvhpCf-c8ooK1bbPE&rI`NcAfb~(miUzA#i eK#nKfW$_D&Hmgp2R_U4m00002>*!C zxhU{fj4J>y3VaYpqT+I$OfldZ{0{gZoW#F!^o5$lUpp!2OBO$D@pE%W>;t zAx9?he2@14?v?^S6B=hyPsw078?vOqcgmr6HgHM!gJNLGsv5v;OvkcBwv0wMo|by^ z33!*fbr1HI3Lb-pIRg0=drBRqPZGf1cry5mox{~Qdq!e6rr~2$WNT=>Fjj&Nyoo|u ziRG9SlKm|-{s(Y5VP6(MkO}`L9EzZJ<7L#t;-SFpQH@P0-&%A9{C#XoA8;Kn!rqc^ z0N0}}D)DfRsl7j;|66RwL^R@7*iYmul$L0pXLI;x<9+~crhFUm1#i+buMR6BP*r)h zpe|g>GX%Qu9CMS#&A5SQiSG6uQ**$V#3tH_^$GjBfPcuQTLUg)bp)d~(q}}ZTzd-q zBlO-9DOeo=+lN)SnjMx`;)bUpUDn`S*xK@B&kQujclu)O%|x4Blm&O=S8D5-g;(Kg z%mbf-UAPdJYr?$bc>fvTbkArG-;M$mJUP1J$n+-kETLKU^kZhcdkTO*M{EX_^VZO( zBl^UA90=%Jj4h>Ao=o)K*C9cFXjpQC--dhmglpK4)NMHDKT4&opA= + ** @date 11 4, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vposter.h" +#include +#include +#include + +#include "../../utils/def.h" + +//--------------------------------------------------------------------------------------------------------------------- +VPoster::VPoster(const QPrinter *printer) + :printer(printer), allowence(38)//1 cm +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VPoster::Generate(const QImage &image, int page, int pages) const +{ + QVector poster; + + if (printer == nullptr) + { + return poster; + } + + const int rows = CountRows(image.rect().height()); + const int colomns = CountColomns(image.rect().width()); + + for (int i=0; i < rows; i++) + { + for (int j=0; j< colomns; j++) + { + QImage img = Cut(i, j, image); + img = Borders(rows, colomns, i, j, img, page, pages); + poster.append(img); + } + } + + return poster; +} + +//--------------------------------------------------------------------------------------------------------------------- +int VPoster::CountRows(int height) const +{ + const qreal imgLength = height; + const qreal pageLength = PageRect().height(); + + // Example + // ― ― + // * * + // * * + // * * + // * * ― + // ― ― * + // * * + // * * + // * * ― + // * ― * + // — * + // * * + // * * ― + // * ― * + // * * + // — * + // * * ― + // * ― * <-(2) + // * + * + // * + * + // — + * ― <-(4) + // ^ ^ ― * + //(3) (1) * + // * + // * + // ― + + const int pCount = qCeil(imgLength/pageLength);// Pages count without allowence (or allowence = 0) (3) + + // Calculate how many pages will be after using allowence. + // We know start pages count. This number not enought because + // each n-1 pages add (n-1)*allowence length to page (1). + const qreal addionalLength = (pCount-1)*allowence; + + // Calculate additional length form pages that will cover this length (2). + // In the end add page length (3). + // Bottom page have mandatory border (4) + return qCeil((addionalLength + + qCeil(addionalLength/pageLength)*allowence + allowence + imgLength)/pageLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VPoster::CountColomns(int width) const +{ + const qreal imgLength = width; + const qreal pageLength = PageRect().width(); + + // Example + // |----|----|----|----| <- (3) + // |----|+++++++++++++++ + // |----|+++++++++++ + // |----|+++++++ + // |----|+++ <- (1) + // |----| + // ^ + // (2) + const int pCount = qCeil(imgLength/pageLength);// Pages count without allowence (or allowence = 0) (3) + + // Calculate how many pages will be after using allowence. + // We know start pages count. This number not enought because + // each n-1 pages add (n-1)*allowence length to page (1). + const qreal addionalLength = (pCount-1)*allowence; + + // Calculate additional length form pages that will cover this length (2). + // In the end add page length (3). + return qCeil((addionalLength + qCeil(addionalLength/pageLength)*allowence + imgLength)/pageLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +QImage VPoster::Cut(int i, int j, const QImage &image) const +{ + const int x = j*PageRect().width() - j*allowence; + const int y = i*PageRect().height() - i*allowence; + + SCASSERT(x <= image.rect().width()); + SCASSERT(y <= image.rect().height()); + + QRect copyRect(x, y, PageRect().width(), PageRect().height()); + + if (not image.rect().contains(copyRect)) + { + QImage fullPage(copyRect.size(), image.format()); + fullPage.fill(Qt::white); + + copyRect = image.rect().intersected(copyRect); + + QPainter painter(&fullPage); + painter.drawImage(QPointF(), image.copy( copyRect)); + painter.end(); + + return fullPage; + } + else + { + return image.copy(copyRect); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QImage VPoster::Borders(int rows, int colomns, int i, int j, QImage &image, int page, int pages) const +{ + QPainter painter(&image); + + QPen pen = QPen(Qt::NoBrush, 1, Qt::DashLine); + pen.setColor(Qt::black); + painter.setPen(pen); + + if (j != 0) + {// Left border + painter.drawLine(QLine(0, 0, 0, image.rect().height())); + painter.drawImage(QPoint(0, image.rect().height()-allowence), QImage("://scissors_vertical.png")); + } + + if (j != colomns-1) + {// Right border + painter.drawLine(QLine(image.rect().width()-allowence, 0, + image.rect().width()-allowence, image.rect().height())); + } + + if (i != 0) + {// Top border + painter.drawLine(QLine(0, 0, image.rect().width(), 0)); + painter.drawImage(QPoint(image.rect().width()-allowence, 0), QImage("://scissors_horizontal.png")); + } + + // Bottom border (mandatory) + painter.drawLine(QLine(0, image.rect().height()-allowence, + image.rect().width(), image.rect().height()-allowence)); + if (i == rows-1) + { + painter.drawImage(QPoint(image.rect().width()-allowence, image.rect().height()-allowence), + QImage("://scissors_horizontal.png")); + } + + // Labels + const int layoutX = 15; + const int layoutY = 5; + QRect labels(layoutX, image.rect().height()-allowence+layoutY, + image.rect().width()-(allowence+layoutX), allowence-layoutY); + painter.drawText(labels, Qt::AlignLeft, tr("Grid ( %1 , %2 )").arg(i).arg(j)); + painter.drawText(labels, Qt::AlignHCenter, tr("Page %1 of %2").arg(i*(colomns)+j+1).arg(rows*colomns)); + if (pages > 1) + { + painter.drawText(labels, Qt::AlignRight, tr("Sheet %1 of %2").arg(page).arg(pages)); + } + + painter.end(); + return image; +} + +//--------------------------------------------------------------------------------------------------------------------- +QRect VPoster::PageRect() const +{ + + const QRectF rect = printer->pageRect(QPrinter::Millimeter); + QRect pageRect(qFloor(ToPixel(rect.x())), qFloor(ToPixel(rect.y())), qFloor(ToPixel(rect.width())), + qFloor(ToPixel(rect.height()))); + return pageRect; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VPoster::ToPixel(qreal val) const +{ + return val / 25.4 * printer->resolution(); // Mm to pixels with current dpi. +} diff --git a/src/libs/vlayout/vposter.h b/src/libs/vlayout/vposter.h new file mode 100644 index 000000000..334358cf8 --- /dev/null +++ b/src/libs/vlayout/vposter.h @@ -0,0 +1,60 @@ +/************************************************************************ + ** + ** @file vposter.h + ** @author Roman Telezhynskyi + ** @date 11 4, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VPOSTER_H +#define VPOSTER_H + +#include +#include +#include + +class QPrinter; + +class VPoster +{ + Q_DECLARE_TR_FUNCTIONS(VPoster) +public: + VPoster(const QPrinter *printer); + + QVector Generate(const QImage &image, int page, int pages = 1) const; +private: + const QPrinter *printer; + unsigned int allowence; + + int CountRows(int height) const; + int CountColomns(int width) const; + + QImage Cut(int i, int j, const QImage &image) const; + QImage Borders(int rows, int colomns, int i, int j, QImage &image, int page, int pages) const; + + QRect PageRect() const; + + qreal ToPixel(qreal val) const; +}; + +#endif // VPOSTER_H diff --git a/src/utils/def.h b/src/utils/def.h new file mode 100644 index 000000000..cd02e81c2 --- /dev/null +++ b/src/utils/def.h @@ -0,0 +1,92 @@ +/************************************************************************ + ** + ** @file def.h + ** @author Roman Telezhynskyi + ** @date 11 4, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef DEF_H +#define DEF_H + +#include +#include + +/* + * This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow + * you to continue afterwards should you choose to. + * idea: Q_ASSERT no longer pauses debugger - http://qt-project.org/forums/viewthread/13148 + * Usefull links: + * 1. What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__? - + * https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func + * + * 2. Windows Predefined Macros - http://msdn.microsoft.com/library/b0084kay.aspx + * + * 3. Windows DebugBreak function - http://msdn.microsoft.com/en-us/library/ms679297%28VS.85%29.aspx + * + * 4. Continue to debug after failed assertion on Linux? [C/C++] - + * https://stackoverflow.com/questions/1721543/continue-to-debug-after-failed-assertion-on-linux-c-c + */ +#ifndef V_NO_ASSERT +#ifdef Q_OS_WIN32 +#ifdef Q_CC_MSVC +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __FUNCSIG__, __FILE__, __LINE__); \ + DebugBreak(); \ + } \ +} \ + +#else // GCC (Windows) + +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ + DebugBreak(); \ + } \ +} \ + +#endif /*Q_CC_MSVC*/ +#else // UNIX +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ + std::raise(SIGTRAP); \ + } \ +} \ + +#endif /* Q_OS_WIN32 */ +#else // define but disable this function if debugging is not set +#define SCASSERT(cond) qt_noop(); +#endif /* V_NO_ASSERT */ + +#endif // DEF_H diff --git a/src/utils/utils.pri b/src/utils/utils.pri index 851661377..0fc1408a4 100644 --- a/src/utils/utils.pri +++ b/src/utils/utils.pri @@ -1,3 +1,4 @@ HEADERS += \ $$PWD/logging.h \ - $$PWD/vmath.h + $$PWD/vmath.h \ + $$PWD/def.h From 130063d690bd59c9fe0cc097a36d66581f3df3e6 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 11 Apr 2015 14:22:50 +0300 Subject: [PATCH 2/5] Menu bar. Theme icons for actions print and print preview. --HG-- branch : feature --- .../16x16/actions/document-print-preview.png | Bin 0 -> 544 bytes .../16x16/actions/document-print.png | Bin 0 -> 478 bytes .../24x24/actions/document-print-preview.png | Bin 0 -> 1596 bytes .../24x24/actions/document-print.png | Bin 0 -> 1346 bytes .../32x32/actions/document-print-preview.png | Bin 0 -> 2226 bytes .../32x32/actions/document-print.png | Bin 0 -> 1963 bytes src/app/share/resources/theme.qrc | 6 ++ src/app/tablewindow.ui | 57 ++++++++++++++++++ 8 files changed, 63 insertions(+) create mode 100644 src/app/share/resources/icons/win.icon.theme/16x16/actions/document-print-preview.png create mode 100644 src/app/share/resources/icons/win.icon.theme/16x16/actions/document-print.png create mode 100755 src/app/share/resources/icons/win.icon.theme/24x24/actions/document-print-preview.png create mode 100755 src/app/share/resources/icons/win.icon.theme/24x24/actions/document-print.png create mode 100644 src/app/share/resources/icons/win.icon.theme/32x32/actions/document-print-preview.png create mode 100644 src/app/share/resources/icons/win.icon.theme/32x32/actions/document-print.png diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-print-preview.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/document-print-preview.png new file mode 100644 index 0000000000000000000000000000000000000000..7441695cdb0472ef5f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Tu_LTE(| zoqkOR+Skt4d-LYKd+$3gW?GnO5%8a!&Aa!V-}$ z27mw{2m+Q)r|ncKwb1ryKItu`klanv>r8RyS8X7`d zThzF5GU5wBFv{PPtsJ&Y#{0 z=<4bQK+#jD-v5qsZ6r`?OH{g6jjLEF_Qd1y?+wGe^>F&(hlZgSXJ=>s8=&ht0Ag)z ztu3Z$8bSy##I+{k_99L+|zV z^`&F6*dxxlxO(*}0Du9&#Kb3X9J^^`~F z4qewVFfahywxN{TEJd}v&uUCWU<@Fto`u5^baZsUah$kiS#iVAEdbC@o;-;oM-Icb zOKvReg6 zDFJ}8*{o+->mVX5EG(c{ETF%?ABjX_bCMdxImgn{5~il6;QJEMXge4Kxo+8aoN^VA zOeO(C zLgX`(v41_`+aYI+frvuG2M_k_?%5q}jOy9Xj9F`zd*{yY834uY?)?jfrlhgl%Lax3001I- zR9JLVZ)S9NVRB^v0C?IfFE7{2%*!rLPAo{(%P&d?05;eLSP)anTmS$707*qoM6N<$ Eg6|e@MF0Q* literal 0 HcmV?d00001 diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-print-preview.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-print-preview.png new file mode 100644 index 0000000000000000000000000000000000000000..d28c6e999e46a73f3e3a2bba03a916ebc2043441 GIT binary patch literal 2226 zcmV;j2u=5iP)C)s+5PS>O(66 zLZYapQb`C&1+<7;6`B$t;9Q&-$Hb1kw&TQ?#Ibkn?8T1P>%GkGdgsyyLlmljf?|&J zX&z?gJ7>Q0pELgvSVZ*n^z4#l`QcnHcS+NZX;P_FD4k9Z#pCg@WHLE3J3BiQ3|^X?n~R^7 z7fV2Kaq;5?1qFg(7>J^XEX$b9X6$x5ZnxX3>$+DI#k(a*#%eV)G<2R_yLR~&ML)aI(d0Z7#o`)8jbv6Q3Tkm*5>?tN1Y@|2!enh z2vGz*+zlVUmuP+D`RbBw4&o6vf|*vb?ElV5~Ejp4%S^`B(MzpDQyLR^nZLGe0OR z#b&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>|3||Y}?=ew&(Kskx}E>XLo9)r6qfT+kk?_BKbx<{nW1;Uwq*&BU9liWB2ae zMpILBD{wDR#v=aQd?WeJKfTa86`3~PdHZeSfd_taUJ!)GfLd;FPs#N(C@k{4vGu_% zYy0~8IDX0qoV5vf1^@s607*qoM6N<$f?NYi ASO5S3 literal 0 HcmV?d00001 diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-print.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/document-print.png new file mode 100644 index 0000000000000000000000000000000000000000..17f4bcc097d99a16c35ffb8afa1c7a06f54f82e9 GIT binary patch literal 1963 zcmV;c2UPfpP)?$1x?fNcs%(1{(RfE^Cd~zCCdsfmqvH@ZBCy)9egYVs;jF# zfk5D8x7&>n0>^Q_l(ubS+cuVEVcRz8>1hlM3^Oq?_N&K2!0mFa_xZeKvMeKnKnO7p z`Yn?)9 zcDlOi|M2Ojmr~NBf*(6}Z29%;*S~977OJWu%QCVoqbLfJB+aIf5JI5qIS=s z^t2>NzmODVXJh+7gAt$pSO_CGEzMKp^<^x&PEizW+eQdMEE=V|=QellwBL@$XRd!G z0++5e=(4Qrm1X&;EUQ(v<6y-i$WC&nlS=HINF*>Vlkm(8Q&Ur9W@eI^nTgx&M%Oho zZ8mKiro&^5j)b^7)Oo3)aX37$(qh2XHCH{7tnN`%?U<(P6~Yn3B2&a7(_p1=9D(In zBois*xh|8*>$nq0bEL(+`A_|nV2{A6WOMto5M=PzE~qAA)b zO;z3oAFTd;9^JQm9WW(k~l zDxsH!ogcVBj{Atl)CFYyc(L931TIYg^jY)kW*)Q3eMG2nK^> zc)es~W#V>wP&Ew!NYbpue&O?A7%7s;BpF^Wu|%9$EJoFi-E7@fMY=Zw)$L;RZajEsypjt%$6$1w~8RaIzdX`!a(G6REygr}!TB@<+1W#VzU zXUBj8IGE<_2u#ytdU~3YWy^T+2QRU%vJwY@$CJjL?hYF2uaQa`NRmWuAi%QaCA@m% z)tw`uP@OU~G{h566mk6cajsmx!gs#6pQUAM*!%1O%GZ?POHb!U{SD5Y`;gwAUM3zq zAR3LJ>pE_?8{xq4$S_qqcJR|zenwti0hVRrNl&A-`34=Wt(c~b=F(WTauq(Wk2Al2 zr+*|AasjefyLRmvzu*6YW4kgA{p1jO!6xeJuM-_?U@8*D@AI&}qLNiBR#2FqkEUzX zUBAZ3Q>SRU)d;}8ec$Fczdk`nM>C<(QJ(qc9(ubw=Fns>#A~m; zGd4E%0T2TE#Q6RDuCr%9XnkhS-W4t3?-M6WzEGOc>i!<({IJb=cz8*T-T2XZuC8ecgc)fgh_U!Q4bLZYN z45J3P2iylt5ekLg_4{*v+;dM*(;h+c8dPn{CKel`wfA$ndxP{0MF>Umu$%x(-4fpj z#ObR0E1g}PG&MC5kH`4S#ZM?HSk8m-DH?CxA}8RdqI?~}V2ktm>u>yVczF0vz$kDR zn3}iZR6PEEU*GMO@kn&j!7VGb41a*Q5uxk;2+7b0_XZPm4COHtT~0<`KD(dJVq2NX z5C1UpFhug@BR6+ zBS#LE@87?_VCAaSbhNc&q!L`cdd2?T$&>F64i3M+pzE2%Y+o$+%76<9c)i|b&mDN~ zz?yZHyNipm2wPU@Zo|=v%NLB%oN=_41OElFi$icons/win.icon.theme/16x16/actions/help-contents.png icons/win.icon.theme/24x24/actions/help-contents.png icons/win.icon.theme/32x32/actions/help-contents.png + icons/win.icon.theme/16x16/actions/document-print.png + icons/win.icon.theme/24x24/actions/document-print.png + icons/win.icon.theme/32x32/actions/document-print.png + icons/win.icon.theme/16x16/actions/document-print-preview.png + icons/win.icon.theme/24x24/actions/document-print-preview.png + icons/win.icon.theme/32x32/actions/document-print-preview.png diff --git a/src/app/tablewindow.ui b/src/app/tablewindow.ui index 11bcf6891..32a551248 100644 --- a/src/app/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -133,6 +133,42 @@ + + + + 0 + 0 + 1000 + 25 + + + + + File + + + + + + + + + + Edit + + + + + + + Layout + + + + + + + false @@ -197,6 +233,27 @@ Layout + + + + + + Print pre&view... + + + + + + + + &Print... + + + + + Print to p&df + + From fc54866019bc1215de60dd707273cafefef4d07d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 11 Apr 2015 17:30:49 +0300 Subject: [PATCH 3/5] Action print preview. --HG-- branch : feature --- src/app/main.cpp | 1 + src/app/tablewindow.cpp | 134 ++++++++++++++++++++++++++++++++++++++-- src/app/tablewindow.h | 31 ++++++---- src/app/tablewindow.ui | 25 +++++++- 4 files changed, 173 insertions(+), 18 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 1bf5555fb..d5f8dcaa5 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -51,6 +51,7 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(schema); Q_INIT_RESOURCE(theme); Q_INIT_RESOURCE(flags); + Q_INIT_RESOURCE(icons); QT_REQUIRE_VERSION(argc, argv, "5.0.0"); diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index 8d0d2d6ed..c7dc9c2f3 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -36,10 +36,12 @@ #include "../../libs/vlayout/vlayoutgenerator.h" #include "../dialogs/app/dialoglayoutprogress.h" #include "../dialogs/app/dialogsavelayout.h" +#include "../../libs/vlayout/vposter.h" #include #include #include +#include #include #ifdef Q_OS_WIN @@ -78,6 +80,7 @@ TableWindow::TableWindow(QWidget *parent) connect(ui->actionSave, &QAction::triggered, this, &TableWindow::SaveLayout); connect(ui->actionLayout, &QAction::triggered, this, &TableWindow::Layout); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &TableWindow::ShowPaper); + connect(ui->actionPrint_pre_view, &QAction::triggered, this, &TableWindow::PrintPreview); } //--------------------------------------------------------------------------------------------------------------------- @@ -238,7 +241,7 @@ void TableWindow::ShowPaper(int index) if (index < 0 || index > scenes.size()) { ui->view->setScene(tempScene); - ui->actionSave->setEnabled(false); + EnableActions(false); } else { @@ -248,6 +251,76 @@ void TableWindow::ShowPaper(int index) ui->view->fitInView(ui->view->scene()->sceneRect(), Qt::KeepAspectRatio); } +//--------------------------------------------------------------------------------------------------------------------- +void TableWindow::PrintPreview() +{ + QPrinterInfo def = QPrinterInfo::defaultPrinter(); + + //if there is no default printer set the print preview won't show + if(def.isNull() || def.printerName().isEmpty()) + { + if(QPrinterInfo::availablePrinters().isEmpty()) + { + QMessageBox::critical(this, tr("Print error"), + tr("Cannot proceed because there are no available printers in your system."), + QMessageBox::Ok); + return; + } + else + { + def = QPrinterInfo::availablePrinters().first(); + } + } + + QPrinter printer(def, QPrinter::ScreenResolution); + printer.setResolution(static_cast(VApplication::PrintDPI)); + + QPrintPreviewDialog preview(&printer); + connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TableWindow::Print); + preview.exec(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void TableWindow::Print(QPrinter *printer) +{ + if (printer == nullptr) + { + return; + } + + const QVector images = AllSheets(); + + VPoster posterazor(printer); + QVector poster; + for (int i=0; i < images.size(); i++) + { + poster += posterazor.Generate(images.at(i), i+1, images.size()); + } + + QPainter painter; + if (not painter.begin(printer)) + { // failed to open file + qWarning("failed to open file, is it writable?"); + return; + } + + for (int i=0; i < poster.size(); i++) + { + painter.drawImage(QPointF(), poster.at(i)); + + if (i+1 < poster.size()) + { + if (not printer->newPage()) + { + qWarning("failed in flushing page to disk, disk full?"); + return; + } + } + } + + painter.end(); +} + //--------------------------------------------------------------------------------------------------------------------- void TableWindow::Layout() { @@ -281,8 +354,8 @@ void TableWindow::Layout() { case LayoutErrors::NoError: ClearLayout(); - papers = lGenerator.GetPapersItems(); - details = lGenerator.GetAllDetails(); + papers = lGenerator.GetPapersItems();// Blank sheets + details = lGenerator.GetAllDetails();// All details CreateShadows(); CreateScenes(); PrepareSceneList(); @@ -462,6 +535,49 @@ void TableWindow::ObjFile(const QString &name, int i) const } } +//--------------------------------------------------------------------------------------------------------------------- +QVector TableWindow::AllSheets() +{ + QVector images; + for (int i=0; i < scenes.size(); ++i) + { + QGraphicsRectItem *paper = qgraphicsitem_cast(papers.at(i)); + if (paper) + { + // Hide shadow and paper border + QBrush *brush = new QBrush(); + brush->setColor( QColor( Qt::white ) ); + scenes[i]->setBackgroundBrush( *brush ); + shadows[i]->setVisible(false); + paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));// border + + // Render png + const QRectF r = paper->rect(); + // Create the image with the exact size of the shrunk scene + QImage image(QSize(static_cast(r.width()), static_cast(r.height())), QImage::Format_RGB32); + image.fill(Qt::white); + QPainter painter(&image); + painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap, + Qt::RoundJoin)); + painter.setBrush ( QBrush ( Qt::NoBrush ) ); + scenes.at(i)->render(&painter); + painter.end(); + images.append(image); + + // Resore + paper->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); + brush->setColor( QColor( Qt::gray ) ); + brush->setStyle( Qt::SolidPattern ); + scenes[i]->setBackgroundBrush( *brush ); + shadows[i]->setVisible(true); + delete brush; + } + } + return images; +} + //--------------------------------------------------------------------------------------------------------------------- void TableWindow::ClearLayout() { @@ -470,6 +586,7 @@ void TableWindow::ClearLayout() shadows.clear(); papers.clear(); ui->listWidget->clear(); + EnableActions(false); } //--------------------------------------------------------------------------------------------------------------------- @@ -529,7 +646,7 @@ void TableWindow::PrepareSceneList() if (scenes.isEmpty() == false) { ui->listWidget->setCurrentRow(0); - ui->actionSave->setEnabled(true); + EnableActions(true); } } @@ -587,3 +704,12 @@ QMap TableWindow::InitFormates() const } return extByMessage; } + +//--------------------------------------------------------------------------------------------------------------------- +void TableWindow::EnableActions(bool enable) +{ + ui->actionSave->setEnabled(enable); + ui->actionSave_to_p_df->setEnabled(enable); + ui->actionPrint_pre_view->setEnabled(enable); + ui->action_Print->setEnabled(enable); +} diff --git a/src/app/tablewindow.h b/src/app/tablewindow.h index 171d3495f..0a55e4f76 100644 --- a/src/app/tablewindow.h +++ b/src/app/tablewindow.h @@ -54,12 +54,13 @@ public: ~TableWindow(); public slots: - void ModelChosen(QVector listDetails, const QString &fileName, - const QString &description); - void Layout(); - void StopTable(); - void SaveLayout(); - void ShowPaper(int index); + void ModelChosen(QVector listDetails, const QString &fileName, const QString &description); + void Layout(); + void StopTable(); + void SaveLayout(); + void ShowPaper(int index); + void PrintPreview(); + void Print (QPrinter *printer); signals: /** @brief closed emit if window is closing. */ @@ -91,13 +92,15 @@ private: QGraphicsScene* tempScene; - void SvgFile(const QString &name, int i)const; - void PngFile(const QString &name, int i)const; - void PdfFile(const QString &name, int i)const; - void EpsFile(const QString &name, int i)const; - void PsFile(const QString &name, int i)const; - void PdfToPs(const QStringList ¶ms)const; - void ObjFile(const QString &name, int i)const; + void SvgFile(const QString &name, int i)const; + void PngFile(const QString &name, int i)const; + void PdfFile(const QString &name, int i)const; + void EpsFile(const QString &name, int i)const; + void PsFile(const QString &name, int i)const; + void PdfToPs(const QStringList ¶ms)const; + void ObjFile(const QString &name, int i)const; + + QVector AllSheets(); void ClearLayout(); void CreateShadows(); @@ -105,6 +108,8 @@ private: void PrepareSceneList(); QIcon ScenePreview(int i) const; QMap InitFormates() const; + + void EnableActions(bool enable); }; #endif // TABLEWINDOW_H diff --git a/src/app/tablewindow.ui b/src/app/tablewindow.ui index 32a551248..a3fdd5d31 100644 --- a/src/app/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -39,7 +39,7 @@ - toolBar + Main toolbar @@ -169,6 +169,20 @@ + + + Toolbar print + + + TopToolBarArea + + + false + + + + + false @@ -234,6 +248,9 @@ + + false + @@ -242,6 +259,9 @@ + + false + @@ -250,6 +270,9 @@ + + false + Print to p&df From e97cceb65bea6af414255c8848924e89b8be9492 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 11 Apr 2015 18:16:30 +0300 Subject: [PATCH 4/5] Actions print. --HG-- branch : feature --- src/app/tablewindow.cpp | 20 ++++++++++++++++++++ src/app/tablewindow.h | 2 ++ src/app/tablewindow.ui | 8 +++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index c7dc9c2f3..f6471f3a6 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #ifdef Q_OS_WIN @@ -81,6 +82,7 @@ TableWindow::TableWindow(QWidget *parent) connect(ui->actionLayout, &QAction::triggered, this, &TableWindow::Layout); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &TableWindow::ShowPaper); connect(ui->actionPrint_pre_view, &QAction::triggered, this, &TableWindow::PrintPreview); + connect(ui->action_Print, &QAction::triggered, this, &TableWindow::LayoutPrint); } //--------------------------------------------------------------------------------------------------------------------- @@ -274,7 +276,10 @@ void TableWindow::PrintPreview() QPrinter printer(def, QPrinter::ScreenResolution); printer.setResolution(static_cast(VApplication::PrintDPI)); + printer.setCreator(qApp->applicationDisplayName()+" "+qApp->applicationVersion()); + printer.setDocName(fileName); + // display print preview dialog QPrintPreviewDialog preview(&printer); connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TableWindow::Print); preview.exec(); @@ -321,6 +326,21 @@ void TableWindow::Print(QPrinter *printer) painter.end(); } +//--------------------------------------------------------------------------------------------------------------------- +void TableWindow::LayoutPrint() +{ + // display print dialog and if accepted print + QPrinter printer; + printer.setCreator(qApp->applicationDisplayName()+" "+qApp->applicationVersion()); + printer.setDocName(fileName); + QPrintDialog dialog( &printer, this ); + if ( dialog.exec() == QDialog::Accepted ) + { + printer.setResolution(static_cast(VApplication::PrintDPI)); + Print( &printer ); + } +} + //--------------------------------------------------------------------------------------------------------------------- void TableWindow::Layout() { diff --git a/src/app/tablewindow.h b/src/app/tablewindow.h index 0a55e4f76..f7221a94f 100644 --- a/src/app/tablewindow.h +++ b/src/app/tablewindow.h @@ -42,6 +42,7 @@ namespace Ui class QGraphicsScene; class QGraphicsRectItem; +class QPrinter; /** * @brief TableWindow class layout window. @@ -61,6 +62,7 @@ public slots: void ShowPaper(int index); void PrintPreview(); void Print (QPrinter *printer); + void LayoutPrint(); signals: /** @brief closed emit if window is closing. */ diff --git a/src/app/tablewindow.ui b/src/app/tablewindow.ui index a3fdd5d31..d34e4f652 100644 --- a/src/app/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -193,11 +193,14 @@ - Save + &Save As... Save layout + + Ctrl+S + @@ -268,6 +271,9 @@ &Print... + + Ctrl+P + From 3c96dfddcb2e4e436bb41cd129e8a9f10b5127b4 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 11 Apr 2015 18:33:43 +0300 Subject: [PATCH 5/5] Action print to pdf. --HG-- branch : feature --- src/app/share/resources/icon.qrc | 1 + src/app/share/resources/icon/32x32/pdf.png | Bin 0 -> 3753 bytes src/app/tablewindow.cpp | 21 +++++++++++++++++++++ src/app/tablewindow.h | 1 + src/app/tablewindow.ui | 4 ++++ 5 files changed, 27 insertions(+) create mode 100644 src/app/share/resources/icon/32x32/pdf.png diff --git a/src/app/share/resources/icon.qrc b/src/app/share/resources/icon.qrc index 329cd555f..439657321 100644 --- a/src/app/share/resources/icon.qrc +++ b/src/app/share/resources/icon.qrc @@ -55,5 +55,6 @@ icon/16x16/landscape.png icon/16x16/portrait.png icon/16x16/template.png + icon/32x32/pdf.png diff --git a/src/app/share/resources/icon/32x32/pdf.png b/src/app/share/resources/icon/32x32/pdf.png new file mode 100644 index 0000000000000000000000000000000000000000..0c65ce2ffa120bfa1e6eec8c70dc6e4961be08e0 GIT binary patch literal 3753 zcmV;a4p#ArP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvY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DXbSWm_+rD(r;HCuiD{IBN2 zhYRVqZ%qIp1OQzbS4wsL3M(tB{`9GGub<}Tx@bR{f1W&1&1O@TUcXjGV}Yrc#VA zEM#^zHuiw&TRBiO4Cf%r6*0ieckclBJ{;!j;o&YBDJ8!}qnt{K5P~5gNCX1>3mHFK z!Vd?29T`!}J>r82G?c=$4FH3{ZXm$7XJ=jZd^6B6O@9AaNaXh!?(FQSey`4%UABBP zAf?1G3@pp)OOU}}5Gm#Dk?`{J(jT?%vFtN%?SN7WDJ9$6+rElxYis25c{EKUlgW_J z=h1Z?r4*S=rmM_%azIMy)Cgc^X2$b=Z*LE!6iZ7>SAf)RJA0eH?!cW(;8yZemQs?- zHC5wxT9^UoH@7)8o;e&$%->41`51E*lpja%TX&SW- zM9W_G)NjjazvMlE3=e;w5i)UF@Z%t@NSuU5kxVUiMX`06P z_&CSM$DSuZwOV!L5{U%WYL!GHabq9dDg&uh$~XGS$w|)>@W`5`Nh+1XG|k>ipp>Fe zD4^>)u~>|glM|Fu2qB1dMz%_&;?R{!g?K#f^o*_7a|xuB%+Ag_5!tD>X@F!h>Cnk! z64Nvt9k*OhB~VInbado&x29=~j*fDAdP*b`pRz6~V*>wpkqurt7Z zzPY){*49?v=T9Mo))|~F)w$`MFlistWidget, &QListWidget::currentRowChanged, this, &TableWindow::ShowPaper); connect(ui->actionPrint_pre_view, &QAction::triggered, this, &TableWindow::PrintPreview); connect(ui->action_Print, &QAction::triggered, this, &TableWindow::LayoutPrint); + connect(ui->actionSave_to_p_df, &QAction::triggered, this, &TableWindow::PrintToPdf); } //--------------------------------------------------------------------------------------------------------------------- @@ -341,6 +342,26 @@ void TableWindow::LayoutPrint() } } +//--------------------------------------------------------------------------------------------------------------------- +void TableWindow::PrintToPdf() +{ + // display print dialog and if accepted print + QPrinter printer; + printer.setCreator(qApp->applicationDisplayName()+" "+qApp->applicationVersion()); + printer.setDocName(fileName); + printer.setOutputFormat(QPrinter::PdfFormat); + + const QString fileName = QFileDialog::getSaveFileName(this, tr("Print to pdf"), + QDir::homePath()+"/"+this->fileName+".pdf", + tr("PDF file (*.pdf)")); + if (fileName.isEmpty()) + { + printer.setOutputFileName(fileName); + printer.setResolution(static_cast(VApplication::PrintDPI)); + Print( &printer ); + } +} + //--------------------------------------------------------------------------------------------------------------------- void TableWindow::Layout() { diff --git a/src/app/tablewindow.h b/src/app/tablewindow.h index f7221a94f..c988a6f77 100644 --- a/src/app/tablewindow.h +++ b/src/app/tablewindow.h @@ -63,6 +63,7 @@ public slots: void PrintPreview(); void Print (QPrinter *printer); void LayoutPrint(); + void PrintToPdf(); signals: /** @brief closed emit if window is closing. */ diff --git a/src/app/tablewindow.ui b/src/app/tablewindow.ui index d34e4f652..c3c213e30 100644 --- a/src/app/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -279,6 +279,10 @@ false + + + :/icon/32x32/pdf.png:/icon/32x32/pdf.png + Print to p&df