diff --git a/ChangeLog.txt b/ChangeLog.txt index 6f7921148..5fc43c073 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -47,6 +47,7 @@ - [#808] New feature. Global line width option. - [#814] Make "\" valid character. - [#818] Improve Piece path validation. Check uniqueness. +- [#819] Use OpenGL as render for view. # Version 0.5.1 - [#683] Tool Seam allowance's dialog is off screen on small resolutions. diff --git a/common.pri b/common.pri index cfb085c23..b05b355d2 100644 --- a/common.pri +++ b/common.pri @@ -228,7 +228,8 @@ ISYSTEM += \ -isystem "$$[QT_INSTALL_HEADERS]/QtSvg" \ -isystem "$$[QT_INSTALL_HEADERS]/QtNetwork" \ -isystem "$$[QT_INSTALL_HEADERS]/QtTest" \ - -isystem "$$[QT_INSTALL_HEADERS]/QtConcurrent" + -isystem "$$[QT_INSTALL_HEADERS]/QtConcurrent" \ + -isystem "$$[QT_INSTALL_HEADERS]/QtOpenGL" } else { ISYSTEM += \ -isystem "$$[QT_INSTALL_LIBS]/QtWidgets.framework/Headers/" \ @@ -250,7 +251,9 @@ ISYSTEM += \ -isystem "$$[QT_INSTALL_LIBS]/QtTest.framework/Headers/" \ -isystem "$$[QT_INSTALL_LIBS]/QtTest.framework/Versions/5/Headers/" \ -isystem "$$[QT_INSTALL_LIBS]/QtConcurrent.framework/Headers/" \ - -isystem "$$[QT_INSTALL_LIBS]/QtConcurrent.framework/Versions/5/Headers/" + -isystem "$$[QT_INSTALL_LIBS]/QtConcurrent.framework/Versions/5/Headers/" \ + -isystem "$$[QT_INSTALL_LIBS]/QtOpenGL.framework/Headers/" \ + -isystem "$$[QT_INSTALL_LIBS]/QtOpenGL.framework/Versions/5/Headers/" } # Usefull GCC warnings keys. diff --git a/dist/OBS_debian/debian.control b/dist/OBS_debian/debian.control index c766e1ba6..df193b693 100644 --- a/dist/OBS_debian/debian.control +++ b/dist/OBS_debian/debian.control @@ -8,14 +8,15 @@ Build-Depends: debhelper (>= 8.0.0), g++ (>= 4.7.0), qt5-default (>= 5.2.0), qttools5-dev-tools (>= 5.2.0), - libqt5xmlpatterns5-dev (>= 5.2.0) + libqt5xmlpatterns5-dev (>= 5.2.0), + libqt5opengl5-dev (>= 5.2.0) Standards-Version: 3.9.5 Homepage: https://valentinaproject.bitbucket.io/ Vcs-Browser: https://bitbucket.org/dismine/valentina Package: valentina Architecture: i386 amd64 -Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.2.0) | libqt5core5 (>= 5.2.0), libqt5gui5 (>= 5.2.0) | libqt5gui5-gles (>= 5.2.0), libqt5printsupport5 (>= 5.2.0), libqt5svg5 (>= 5.2.0), libqt5widgets5 (>= 5.2.0), libqt5xml5 (>= 5.2.0), libqt5xmlpatterns5 (>= 5.2.0), libqt5concurrent5(>= 5.2.0), libstdc++6 (>= 4.6), xpdf +Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.2.0) | libqt5core5 (>= 5.2.0), libqt5gui5 (>= 5.2.0) | libqt5gui5-gles (>= 5.2.0), libqt5printsupport5 (>= 5.2.0), libqt5svg5 (>= 5.2.0), libqt5widgets5 (>= 5.2.0), libqt5xml5 (>= 5.2.0), libqt5xmlpatterns5 (>= 5.2.0), libqt5concurrent5(>= 5.2.0), libqt5opengl5 (>= 5.2.0), libstdc++6 (>= 4.6), xpdf Conflicts: seamly2d Description: Pattern making program. Valentina is a cross-platform patternmaking program which allows designers diff --git a/dist/debian/control b/dist/debian/control index c766e1ba6..df193b693 100644 --- a/dist/debian/control +++ b/dist/debian/control @@ -8,14 +8,15 @@ Build-Depends: debhelper (>= 8.0.0), g++ (>= 4.7.0), qt5-default (>= 5.2.0), qttools5-dev-tools (>= 5.2.0), - libqt5xmlpatterns5-dev (>= 5.2.0) + libqt5xmlpatterns5-dev (>= 5.2.0), + libqt5opengl5-dev (>= 5.2.0) Standards-Version: 3.9.5 Homepage: https://valentinaproject.bitbucket.io/ Vcs-Browser: https://bitbucket.org/dismine/valentina Package: valentina Architecture: i386 amd64 -Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.2.0) | libqt5core5 (>= 5.2.0), libqt5gui5 (>= 5.2.0) | libqt5gui5-gles (>= 5.2.0), libqt5printsupport5 (>= 5.2.0), libqt5svg5 (>= 5.2.0), libqt5widgets5 (>= 5.2.0), libqt5xml5 (>= 5.2.0), libqt5xmlpatterns5 (>= 5.2.0), libqt5concurrent5(>= 5.2.0), libstdc++6 (>= 4.6), xpdf +Depends: libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt5core5a (>= 5.2.0) | libqt5core5 (>= 5.2.0), libqt5gui5 (>= 5.2.0) | libqt5gui5-gles (>= 5.2.0), libqt5printsupport5 (>= 5.2.0), libqt5svg5 (>= 5.2.0), libqt5widgets5 (>= 5.2.0), libqt5xml5 (>= 5.2.0), libqt5xmlpatterns5 (>= 5.2.0), libqt5concurrent5(>= 5.2.0), libqt5opengl5 (>= 5.2.0), libstdc++6 (>= 4.6), xpdf Conflicts: seamly2d Description: Pattern making program. Valentina is a cross-platform patternmaking program which allows designers diff --git a/dist/ebuild/valentina-0.0.0_alpha(template_unstable).ebuild b/dist/ebuild/valentina-0.0.0_alpha(template_unstable).ebuild index b9c741981..e1721b09e 100644 --- a/dist/ebuild/valentina-0.0.0_alpha(template_unstable).ebuild +++ b/dist/ebuild/valentina-0.0.0_alpha(template_unstable).ebuild @@ -35,6 +35,7 @@ CDEPEND=" dev-qt/qtprintsupport:5 dev-qt/qtnetwork:5 dev-qt/qtconcurrent:5 + dev-qt/qtopengl:5 app-text/poppler" RDEPEND="${CDEPEND}" DEPEND="${CDEPEND} diff --git a/dist/rpm/valentina.spec b/dist/rpm/valentina.spec index 82d6ef383..d8bb8f129 100644 --- a/dist/rpm/valentina.spec +++ b/dist/rpm/valentina.spec @@ -18,6 +18,7 @@ BuildRequires: pkgconfig(Qt5PrintSupport) BuildRequires: pkgconfig(Qt5Widgets) BuildRequires: pkgconfig(Qt5Xml) BuildRequires: pkgconfig(Qt5Concurrent) +BuildRequires: pkgconfig(Qt5OpenGL) BuildRequires: qt5-qtxmlpatterns-devel >= 5.2.0 BuildRequires: qt5-qtsvg-devel >= 5.2.0 BuildRequires: qt5-qttools-devel >= 5.2.0 diff --git a/src/app/tape/tape.pro b/src/app/tape/tape.pro index 2e70bfa37..2eb3a9479 100644 --- a/src/app/tape/tape.pro +++ b/src/app/tape/tape.pro @@ -7,7 +7,7 @@ # File with common stuff for whole project include(../../../common.pri) -QT += core gui widgets network xml xmlpatterns printsupport svg concurrent +QT += core gui widgets network xml xmlpatterns printsupport svg concurrent opengl # Name of binary file TARGET = tape diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index e78e683c7..0b113c7cf 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -65,6 +65,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent) VSettings *settings = qApp->ValentinaSettings(); ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput()); + ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender()); ui->doubleSpinBoxCurveApproximation->setValue(settings->GetCurveApproximationScale()); ui->doubleSpinBoxCurveApproximation->setMinimum(minCurveApproximationScale); ui->doubleSpinBoxCurveApproximation->setMaximum(maxCurveApproximationScale); @@ -118,10 +119,10 @@ void PreferencesPatternPage::Apply() // Scene antialiasing settings->SetGraphicalOutput(ui->graphOutputCheck->isChecked()); + settings->SetOpenGLRender(ui->checkBoxOpenGLRender->isChecked()); settings->SetCurveApproximationScale(ui->doubleSpinBoxCurveApproximation->value()); settings->SetLineWidth(UnitConvertor(ui->doubleSpinBoxLineWidth->value(), m_oldLineUnit, Unit::Mm)); - qApp->getSceneView()->setRenderHint(QPainter::Antialiasing, ui->graphOutputCheck->isChecked()); - qApp->getSceneView()->setRenderHint(QPainter::SmoothPixmapTransform, ui->graphOutputCheck->isChecked()); + qApp->getSceneView()->SetAntialiasing(ui->graphOutputCheck->isChecked()); /* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a * non-empty stack might delete the command at the current index. Calling setUndoLimit() on a non-empty stack diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui index d12311f7d..2baaaf6b9 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui @@ -7,19 +7,19 @@ 0 0 381 - 705 + 727 Pattern - + Graphical output - + @@ -27,6 +27,20 @@ + + + + Use OpenGL to render a scene. +This option will take an affect after restart. + + + Use OpenGL render + + + false + + + diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 194d35588..35d4308b6 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -3741,9 +3741,7 @@ void MainWindow::ReadSettings() restoreState(settings->GetToolbarsState(), APP_VERSION); // Scene antialiasing - const bool graphOutputValue = settings->GetGraphicalOutput(); - ui->view->setRenderHint(QPainter::Antialiasing, graphOutputValue); - ui->view->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputValue); + ui->view->SetAntialiasing(settings->GetGraphicalOutput()); // Stack limit qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount()); diff --git a/src/app/valentina/valentina.pro b/src/app/valentina/valentina.pro index 2836aa881..f3fb38f4f 100644 --- a/src/app/valentina/valentina.pro +++ b/src/app/valentina/valentina.pro @@ -11,7 +11,7 @@ include(../../../common.pri) # Here we don't see "network" library, but, i think, "printsupport" depend on this library, so we still need this # library in installer. -QT += core gui widgets xml svg printsupport xmlpatterns concurrent +QT += core gui widgets xml svg printsupport xmlpatterns concurrent opengl # Use winextras only for Windows 7+ win32:greaterThan(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 6) { @@ -300,6 +300,7 @@ win32:*g++* { $$[QT_INSTALL_BINS]/icuuc*.dll \ # Different name for different Qt releases $$[QT_INSTALL_BINS]/Qt5Core.dll \ $$[QT_INSTALL_BINS]/Qt5Concurrent.dll \ + $$[QT_INSTALL_BINS]/Qt5OpenGL.dll \ $$[QT_INSTALL_BINS]/Qt5Gui.dll \ $$[QT_INSTALL_BINS]/Qt5Network.dll \ $$[QT_INSTALL_BINS]/Qt5PrintSupport.dll \ diff --git a/src/libs/vmisc/vsettings.cpp b/src/libs/vmisc/vsettings.cpp index a03bb840d..4130d9321 100644 --- a/src/libs/vmisc/vsettings.cpp +++ b/src/libs/vmisc/vsettings.cpp @@ -53,6 +53,7 @@ const QString settingPathsPattern = QStringLiteral("paths/pattern"); const QString settingPathsLayout = QStringLiteral("paths/layout"); const QString settingPatternGraphicalOutput = QStringLiteral("pattern/graphicalOutput"); +const QString settingPatternUseOpenGLRender = QStringLiteral("pattern/useOpenGLRender"); const QString settingPatternKnownMaterials = QStringLiteral("pattern/knownMaterials"); const QString settingPatternRememberMaterials = QStringLiteral("pattern/rememberMaterials"); @@ -152,6 +153,18 @@ void VSettings::SetGraphicalOutput(const bool &value) setValue(settingPatternGraphicalOutput, value); } +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::IsOpenGLRender() const +{ + return value(settingPatternUseOpenGLRender, 0).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetOpenGLRender(bool value) +{ + setValue(settingPatternUseOpenGLRender, value); +} + //--------------------------------------------------------------------------------------------------------------------- qreal VSettings::GetLayoutPaperHeight() const { diff --git a/src/libs/vmisc/vsettings.h b/src/libs/vmisc/vsettings.h index 0f752a9bd..f77a0e56f 100644 --- a/src/libs/vmisc/vsettings.h +++ b/src/libs/vmisc/vsettings.h @@ -68,6 +68,9 @@ public: bool GetGraphicalOutput() const; void SetGraphicalOutput(const bool &value); + bool IsOpenGLRender() const; + void SetOpenGLRender(bool value); + // Layout settings qreal GetLayoutPaperHeight() const; void SetLayoutPaperHeight(qreal value); diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index 991c6f910..9b3f2af4a 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -48,10 +48,18 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) +# include +#else +# include +#endif + #include "../vmisc/def.h" #include "../vmisc/vmath.h" #include "vmaingraphicsscene.h" #include "vsimplecurve.h" +#include "../vmisc/vabstractapplication.h" +#include "../vmisc/vsettings.h" const int GraphicsViewZoom::duration = 300; const int GraphicsViewZoom::updateInterval = 40; @@ -349,17 +357,34 @@ const unsigned long VMainGraphicsView::scrollDelay = 80; */ VMainGraphicsView::VMainGraphicsView(QWidget *parent) : QGraphicsView(parent), - zoom(new GraphicsViewZoom(this)), + zoom(nullptr), showToolOptions(true), isAllowRubberBand(true), m_ptStartPos(), m_oldCursor(), m_currentCursor(Qt::ArrowCursor) { + VSettings *settings = qobject_cast(qApp->Settings()); + if (settings && settings->IsOpenGLRender()) + { + #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) + QOpenGLWidget *viewport = new QOpenGLWidget(); + QSurfaceFormat fmt; + fmt.setSamples(settings->GetGraphicalOutput() ? 10 : 0); + viewport->setFormat(fmt); + + setViewport(viewport); + #else + setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer|QGL::SampleBuffers))); + #endif + } + + zoom = new GraphicsViewZoom(this); + this->setResizeAnchor(QGraphicsView::AnchorUnderMouse); this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - this->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); this->setInteractive(true); + SetAntialiasing(true); connect(zoom, &GraphicsViewZoom::zoomed, this, [this](){emit ScaleChanged(transform().m11());}); } @@ -603,6 +628,15 @@ void VMainGraphicsView::setCurrentCursorShape() m_currentCursor = viewport()->cursor().shape(); } +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::SetAntialiasing(bool value) +{ + setRenderHint(QPainter::Antialiasing, value); + setRenderHint(QPainter::SmoothPixmapTransform, value); + + +} + //--------------------------------------------------------------------------------------------------------------------- void VMainGraphicsView::setShowToolOptions(bool value) { diff --git a/src/libs/vwidgets/vmaingraphicsview.h b/src/libs/vwidgets/vmaingraphicsview.h index 81bd1f8e4..4fe39d60e 100644 --- a/src/libs/vwidgets/vmaingraphicsview.h +++ b/src/libs/vwidgets/vmaingraphicsview.h @@ -113,7 +113,6 @@ class VMainGraphicsView : public QGraphicsView { Q_OBJECT public: - explicit VMainGraphicsView(QWidget *parent = nullptr); void setShowToolOptions(bool value); void AllowRubberBand(bool value); @@ -131,6 +130,8 @@ public: void setCurrentCursorShape(); + void SetAntialiasing(bool value); + signals: /** * @brief MouseRelease help catch mouse release event. diff --git a/src/libs/vwidgets/vwidgets.pro b/src/libs/vwidgets/vwidgets.pro index 1a9171b2f..9f9b80679 100644 --- a/src/libs/vwidgets/vwidgets.pro +++ b/src/libs/vwidgets/vwidgets.pro @@ -7,7 +7,7 @@ # File with common stuff for whole project include(../../../common.pri) -QT += widgets printsupport +QT += widgets printsupport opengl # Name of the library TARGET = vwidgets diff --git a/src/test/CollectionTest/CollectionTest.pro b/src/test/CollectionTest/CollectionTest.pro index b87a42220..a0ec710e8 100644 --- a/src/test/CollectionTest/CollectionTest.pro +++ b/src/test/CollectionTest/CollectionTest.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += testlib widgets printsupport concurrent +QT += testlib widgets printsupport concurrent opengl QT -= gui diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro index 7ed39e52c..21a019488 100644 --- a/src/test/ValentinaTest/ValentinaTest.pro +++ b/src/test/ValentinaTest/ValentinaTest.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core testlib gui printsupport xml xmlpatterns concurrent +QT += core testlib gui printsupport xml xmlpatterns concurrent opengl TARGET = ValentinaTests