Resolved issue #819. Use OpenGL as render for view.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-03-10 16:39:37 +02:00
parent 3d377bcbfd
commit 368c3a871a
18 changed files with 95 additions and 22 deletions

View File

@ -47,6 +47,7 @@
- [#808] New feature. Global line width option. - [#808] New feature. Global line width option.
- [#814] Make "\" valid character. - [#814] Make "\" valid character.
- [#818] Improve Piece path validation. Check uniqueness. - [#818] Improve Piece path validation. Check uniqueness.
- [#819] Use OpenGL as render for view.
# Version 0.5.1 # Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions. - [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -228,7 +228,8 @@ ISYSTEM += \
-isystem "$$[QT_INSTALL_HEADERS]/QtSvg" \ -isystem "$$[QT_INSTALL_HEADERS]/QtSvg" \
-isystem "$$[QT_INSTALL_HEADERS]/QtNetwork" \ -isystem "$$[QT_INSTALL_HEADERS]/QtNetwork" \
-isystem "$$[QT_INSTALL_HEADERS]/QtTest" \ -isystem "$$[QT_INSTALL_HEADERS]/QtTest" \
-isystem "$$[QT_INSTALL_HEADERS]/QtConcurrent" -isystem "$$[QT_INSTALL_HEADERS]/QtConcurrent" \
-isystem "$$[QT_INSTALL_HEADERS]/QtOpenGL"
} else { } else {
ISYSTEM += \ ISYSTEM += \
-isystem "$$[QT_INSTALL_LIBS]/QtWidgets.framework/Headers/" \ -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/Headers/" \
-isystem "$$[QT_INSTALL_LIBS]/QtTest.framework/Versions/5/Headers/" \ -isystem "$$[QT_INSTALL_LIBS]/QtTest.framework/Versions/5/Headers/" \
-isystem "$$[QT_INSTALL_LIBS]/QtConcurrent.framework/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. # Usefull GCC warnings keys.

View File

@ -8,14 +8,15 @@ Build-Depends: debhelper (>= 8.0.0),
g++ (>= 4.7.0), g++ (>= 4.7.0),
qt5-default (>= 5.2.0), qt5-default (>= 5.2.0),
qttools5-dev-tools (>= 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 Standards-Version: 3.9.5
Homepage: https://valentinaproject.bitbucket.io/ Homepage: https://valentinaproject.bitbucket.io/
Vcs-Browser: https://bitbucket.org/dismine/valentina Vcs-Browser: https://bitbucket.org/dismine/valentina
Package: valentina Package: valentina
Architecture: i386 amd64 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 Conflicts: seamly2d
Description: Pattern making program. Description: Pattern making program.
Valentina is a cross-platform patternmaking program which allows designers Valentina is a cross-platform patternmaking program which allows designers

5
dist/debian/control vendored
View File

@ -8,14 +8,15 @@ Build-Depends: debhelper (>= 8.0.0),
g++ (>= 4.7.0), g++ (>= 4.7.0),
qt5-default (>= 5.2.0), qt5-default (>= 5.2.0),
qttools5-dev-tools (>= 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 Standards-Version: 3.9.5
Homepage: https://valentinaproject.bitbucket.io/ Homepage: https://valentinaproject.bitbucket.io/
Vcs-Browser: https://bitbucket.org/dismine/valentina Vcs-Browser: https://bitbucket.org/dismine/valentina
Package: valentina Package: valentina
Architecture: i386 amd64 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 Conflicts: seamly2d
Description: Pattern making program. Description: Pattern making program.
Valentina is a cross-platform patternmaking program which allows designers Valentina is a cross-platform patternmaking program which allows designers

View File

@ -35,6 +35,7 @@ CDEPEND="
dev-qt/qtprintsupport:5 dev-qt/qtprintsupport:5
dev-qt/qtnetwork:5 dev-qt/qtnetwork:5
dev-qt/qtconcurrent:5 dev-qt/qtconcurrent:5
dev-qt/qtopengl:5
app-text/poppler" app-text/poppler"
RDEPEND="${CDEPEND}" RDEPEND="${CDEPEND}"
DEPEND="${CDEPEND} DEPEND="${CDEPEND}

View File

@ -18,6 +18,7 @@ BuildRequires: pkgconfig(Qt5PrintSupport)
BuildRequires: pkgconfig(Qt5Widgets) BuildRequires: pkgconfig(Qt5Widgets)
BuildRequires: pkgconfig(Qt5Xml) BuildRequires: pkgconfig(Qt5Xml)
BuildRequires: pkgconfig(Qt5Concurrent) BuildRequires: pkgconfig(Qt5Concurrent)
BuildRequires: pkgconfig(Qt5OpenGL)
BuildRequires: qt5-qtxmlpatterns-devel >= 5.2.0 BuildRequires: qt5-qtxmlpatterns-devel >= 5.2.0
BuildRequires: qt5-qtsvg-devel >= 5.2.0 BuildRequires: qt5-qtsvg-devel >= 5.2.0
BuildRequires: qt5-qttools-devel >= 5.2.0 BuildRequires: qt5-qttools-devel >= 5.2.0

View File

@ -7,7 +7,7 @@
# File with common stuff for whole project # File with common stuff for whole project
include(../../../common.pri) 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 # Name of binary file
TARGET = tape TARGET = tape

View File

@ -65,6 +65,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
VSettings *settings = qApp->ValentinaSettings(); VSettings *settings = qApp->ValentinaSettings();
ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput()); ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput());
ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender());
ui->doubleSpinBoxCurveApproximation->setValue(settings->GetCurveApproximationScale()); ui->doubleSpinBoxCurveApproximation->setValue(settings->GetCurveApproximationScale());
ui->doubleSpinBoxCurveApproximation->setMinimum(minCurveApproximationScale); ui->doubleSpinBoxCurveApproximation->setMinimum(minCurveApproximationScale);
ui->doubleSpinBoxCurveApproximation->setMaximum(maxCurveApproximationScale); ui->doubleSpinBoxCurveApproximation->setMaximum(maxCurveApproximationScale);
@ -118,10 +119,10 @@ void PreferencesPatternPage::Apply()
// Scene antialiasing // Scene antialiasing
settings->SetGraphicalOutput(ui->graphOutputCheck->isChecked()); settings->SetGraphicalOutput(ui->graphOutputCheck->isChecked());
settings->SetOpenGLRender(ui->checkBoxOpenGLRender->isChecked());
settings->SetCurveApproximationScale(ui->doubleSpinBoxCurveApproximation->value()); settings->SetCurveApproximationScale(ui->doubleSpinBoxCurveApproximation->value());
settings->SetLineWidth(UnitConvertor(ui->doubleSpinBoxLineWidth->value(), m_oldLineUnit, Unit::Mm)); settings->SetLineWidth(UnitConvertor(ui->doubleSpinBoxLineWidth->value(), m_oldLineUnit, Unit::Mm));
qApp->getSceneView()->setRenderHint(QPainter::Antialiasing, ui->graphOutputCheck->isChecked()); qApp->getSceneView()->SetAntialiasing(ui->graphOutputCheck->isChecked());
qApp->getSceneView()->setRenderHint(QPainter::SmoothPixmapTransform, 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 /* 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 * non-empty stack might delete the command at the current index. Calling setUndoLimit() on a non-empty stack

View File

@ -7,19 +7,19 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>381</width> <width>381</width>
<height>705</height> <height>727</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string notr="true">Pattern</string> <string notr="true">Pattern</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
<string>Graphical output</string> <string>Graphical output</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QCheckBox" name="graphOutputCheck"> <widget class="QCheckBox" name="graphOutputCheck">
<property name="text"> <property name="text">
@ -27,6 +27,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBoxOpenGLRender">
<property name="toolTip">
<string>Use OpenGL to render a scene.
This option will take an affect after restart.</string>
</property>
<property name="text">
<string>Use OpenGL render</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>

View File

@ -3741,9 +3741,7 @@ void MainWindow::ReadSettings()
restoreState(settings->GetToolbarsState(), APP_VERSION); restoreState(settings->GetToolbarsState(), APP_VERSION);
// Scene antialiasing // Scene antialiasing
const bool graphOutputValue = settings->GetGraphicalOutput(); ui->view->SetAntialiasing(settings->GetGraphicalOutput());
ui->view->setRenderHint(QPainter::Antialiasing, graphOutputValue);
ui->view->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputValue);
// Stack limit // Stack limit
qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount()); qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount());

View File

@ -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 # Here we don't see "network" library, but, i think, "printsupport" depend on this library, so we still need this
# library in installer. # 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+ # Use winextras only for Windows 7+
win32:greaterThan(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 6) { 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]/icuuc*.dll \ # Different name for different Qt releases
$$[QT_INSTALL_BINS]/Qt5Core.dll \ $$[QT_INSTALL_BINS]/Qt5Core.dll \
$$[QT_INSTALL_BINS]/Qt5Concurrent.dll \ $$[QT_INSTALL_BINS]/Qt5Concurrent.dll \
$$[QT_INSTALL_BINS]/Qt5OpenGL.dll \
$$[QT_INSTALL_BINS]/Qt5Gui.dll \ $$[QT_INSTALL_BINS]/Qt5Gui.dll \
$$[QT_INSTALL_BINS]/Qt5Network.dll \ $$[QT_INSTALL_BINS]/Qt5Network.dll \
$$[QT_INSTALL_BINS]/Qt5PrintSupport.dll \ $$[QT_INSTALL_BINS]/Qt5PrintSupport.dll \

View File

@ -53,6 +53,7 @@ const QString settingPathsPattern = QStringLiteral("paths/pattern");
const QString settingPathsLayout = QStringLiteral("paths/layout"); const QString settingPathsLayout = QStringLiteral("paths/layout");
const QString settingPatternGraphicalOutput = QStringLiteral("pattern/graphicalOutput"); const QString settingPatternGraphicalOutput = QStringLiteral("pattern/graphicalOutput");
const QString settingPatternUseOpenGLRender = QStringLiteral("pattern/useOpenGLRender");
const QString settingPatternKnownMaterials = QStringLiteral("pattern/knownMaterials"); const QString settingPatternKnownMaterials = QStringLiteral("pattern/knownMaterials");
const QString settingPatternRememberMaterials = QStringLiteral("pattern/rememberMaterials"); const QString settingPatternRememberMaterials = QStringLiteral("pattern/rememberMaterials");
@ -152,6 +153,18 @@ void VSettings::SetGraphicalOutput(const bool &value)
setValue(settingPatternGraphicalOutput, 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 qreal VSettings::GetLayoutPaperHeight() const
{ {

View File

@ -68,6 +68,9 @@ public:
bool GetGraphicalOutput() const; bool GetGraphicalOutput() const;
void SetGraphicalOutput(const bool &value); void SetGraphicalOutput(const bool &value);
bool IsOpenGLRender() const;
void SetOpenGLRender(bool value);
// Layout settings // Layout settings
qreal GetLayoutPaperHeight() const; qreal GetLayoutPaperHeight() const;
void SetLayoutPaperHeight(qreal value); void SetLayoutPaperHeight(qreal value);

View File

@ -48,10 +48,18 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QThread> #include <QThread>
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
# include <QOpenGLWidget>
#else
# include <QGLWidget>
#endif
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
#include "vmaingraphicsscene.h" #include "vmaingraphicsscene.h"
#include "vsimplecurve.h" #include "vsimplecurve.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vsettings.h"
const int GraphicsViewZoom::duration = 300; const int GraphicsViewZoom::duration = 300;
const int GraphicsViewZoom::updateInterval = 40; const int GraphicsViewZoom::updateInterval = 40;
@ -349,17 +357,34 @@ const unsigned long VMainGraphicsView::scrollDelay = 80;
*/ */
VMainGraphicsView::VMainGraphicsView(QWidget *parent) VMainGraphicsView::VMainGraphicsView(QWidget *parent)
: QGraphicsView(parent), : QGraphicsView(parent),
zoom(new GraphicsViewZoom(this)), zoom(nullptr),
showToolOptions(true), showToolOptions(true),
isAllowRubberBand(true), isAllowRubberBand(true),
m_ptStartPos(), m_ptStartPos(),
m_oldCursor(), m_oldCursor(),
m_currentCursor(Qt::ArrowCursor) m_currentCursor(Qt::ArrowCursor)
{ {
VSettings *settings = qobject_cast<VSettings *>(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->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
this->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
this->setInteractive(true); this->setInteractive(true);
SetAntialiasing(true);
connect(zoom, &GraphicsViewZoom::zoomed, this, [this](){emit ScaleChanged(transform().m11());}); connect(zoom, &GraphicsViewZoom::zoomed, this, [this](){emit ScaleChanged(transform().m11());});
} }
@ -603,6 +628,15 @@ void VMainGraphicsView::setCurrentCursorShape()
m_currentCursor = viewport()->cursor().shape(); m_currentCursor = viewport()->cursor().shape();
} }
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsView::SetAntialiasing(bool value)
{
setRenderHint(QPainter::Antialiasing, value);
setRenderHint(QPainter::SmoothPixmapTransform, value);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsView::setShowToolOptions(bool value) void VMainGraphicsView::setShowToolOptions(bool value)
{ {

View File

@ -113,7 +113,6 @@ class VMainGraphicsView : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit VMainGraphicsView(QWidget *parent = nullptr); explicit VMainGraphicsView(QWidget *parent = nullptr);
void setShowToolOptions(bool value); void setShowToolOptions(bool value);
void AllowRubberBand(bool value); void AllowRubberBand(bool value);
@ -131,6 +130,8 @@ public:
void setCurrentCursorShape(); void setCurrentCursorShape();
void SetAntialiasing(bool value);
signals: signals:
/** /**
* @brief MouseRelease help catch mouse release event. * @brief MouseRelease help catch mouse release event.

View File

@ -7,7 +7,7 @@
# File with common stuff for whole project # File with common stuff for whole project
include(../../../common.pri) include(../../../common.pri)
QT += widgets printsupport QT += widgets printsupport opengl
# Name of the library # Name of the library
TARGET = vwidgets TARGET = vwidgets

View File

@ -4,7 +4,7 @@
# #
#------------------------------------------------- #-------------------------------------------------
QT += testlib widgets printsupport concurrent QT += testlib widgets printsupport concurrent opengl
QT -= gui QT -= gui

View File

@ -4,7 +4,7 @@
# #
#------------------------------------------------- #-------------------------------------------------
QT += core testlib gui printsupport xml xmlpatterns concurrent QT += core testlib gui printsupport xml xmlpatterns concurrent opengl
TARGET = ValentinaTests TARGET = ValentinaTests