From a7272f8e852d2e5113f58fb5d1f50946330bf68b Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 1 Apr 2022 09:11:58 +0200 Subject: [PATCH 1/3] Fixes for crashes after reducing number of axis --- src/qwt_plot_axis.cpp | 7 ++++--- src/qwt_plot_curve.cpp | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/qwt_plot_axis.cpp b/src/qwt_plot_axis.cpp index a49882fa..523f5edd 100644 --- a/src/qwt_plot_axis.cpp +++ b/src/qwt_plot_axis.cpp @@ -770,14 +770,14 @@ void QwtPlot::updateAxes() { const QRectF rect = item->boundingRect(); - if ( rect.width() >= 0.0 ) + if ( isAxisValid( item->xAxis()) && rect.width() >= 0.0 ) { const QwtAxisId xAxis = item->xAxis(); boundingIntervals[ xAxis.pos ][ xAxis.id ] |= QwtInterval( rect.left(), rect.right() ); } - if ( rect.height() >= 0.0 ) + if ( isAxisValid( item->yAxis()) && rect.height() >= 0.0 ) { const QwtAxisId yAxis = item->yAxis(); boundingIntervals[ yAxis.pos ][ yAxis.id ] |= @@ -831,7 +831,8 @@ void QwtPlot::updateAxes() for ( it = itmList.begin(); it != itmList.end(); ++it ) { QwtPlotItem* item = *it; - if ( item->testItemInterest( QwtPlotItem::ScaleInterest ) ) + if ( item->testItemInterest( QwtPlotItem::ScaleInterest ) && + isAxisValid( item->xAxis() ) && isAxisValid( item->yAxis() ) ) { item->updateScaleDiv( axisScaleDiv( item->xAxis() ), axisScaleDiv( item->yAxis() ) ); diff --git a/src/qwt_plot_curve.cpp b/src/qwt_plot_curve.cpp index 7abd4e4b..c7ddddf2 100644 --- a/src/qwt_plot_curve.cpp +++ b/src/qwt_plot_curve.cpp @@ -1055,6 +1055,9 @@ int QwtPlotCurve::closestPoint( const QPointF& pos, double* dist ) const if ( plot() == NULL || numSamples <= 0 ) return -1; + if ( !plot()->isAxisValid( xAxis() ) || !plot()->isAxisValid( yAxis() ) ) + return -1; + const QwtSeriesData< QPointF >* series = data(); const QwtScaleMap xMap = plot()->canvasMap( xAxis() ); From 886436d42226eb2f978735717da03d4e1a912d55 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Apr 2022 21:50:16 +0200 Subject: [PATCH 2/3] Add curve fitting to step-left curve drawing --- src/qwt_plot_curve.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qwt_plot_curve.cpp b/src/qwt_plot_curve.cpp index c7ddddf2..c5e8fe35 100644 --- a/src/qwt_plot_curve.cpp +++ b/src/qwt_plot_curve.cpp @@ -786,6 +786,8 @@ void QwtPlotCurve::drawSteps( QPainter* painter, points[ip].ry() = yi; } + const bool doFit = (m_data->attributes & Fitted) && m_data->curveFitter; + if ( m_data->paintAttributes & ClipPolygons ) { QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter ); @@ -793,13 +795,23 @@ void QwtPlotCurve::drawSteps( QPainter* painter, const qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); clipRect = clipRect.adjusted(-pw, -pw, pw, pw); - const QPolygonF clipped = QwtClipper::clippedPolygonF( + QPolygonF clipped = QwtClipper::clippedPolygonF( clipRect, polygon, false ); + if (doFit) + { + clipped = m_data->curveFitter->fitCurve(clipped); + } + QwtPainter::drawPolyline( painter, clipped ); } else { + if (doFit) + { + polygon = m_data->curveFitter->fitCurve(polygon); + } + QwtPainter::drawPolyline( painter, polygon ); } From b7c4f89b02f9bcfcbb74dfb8180a1e7039ab1891 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 3 Jan 2024 11:20:34 +0100 Subject: [PATCH 3/3] Add Qt6 support Remove deprecated opengl functions --- .github/workflows/ci.yml | 42 ++++++++++++++++++++-------------------- .gitignore | 1 + CMakeLists.txt | 14 +++++++++++--- src/CMakeLists.txt | 4 ---- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 354b224f..7b5a0f18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,35 +8,35 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] + qtver: [5.12.12, 6.5.3] steps: - name: Checkout - uses: actions/checkout@v2 - - - name: Cache Qt - id: cache-qt - uses: actions/cache@v2 - with: - path: ${{ github.workspace }}/Qt/ - key: ${{ runner.os }}-QtCache-5-12-12 + uses: actions/checkout@v4 - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v3 with: - version: 5.12.12 + version: ${{ matrix.qtver }} dir: "${{ github.workspace }}/Qt/" - cached: ${{ steps.cache-qt.outputs.cache-hit }} + cache: true + cache-key-prefix: ${{ matrix.qtver }}-${{ matrix.os }} - name: Install Linux dependencies if: "contains( matrix.os, 'ubuntu')" run: sudo apt-get install libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev + + - name: Use MSVC (Windows) + uses: ilammy/msvc-dev-cmd@v1 - - name: Build - uses: lukka/run-cmake@v1 - with: - cmakeListsOrSettingsJson: CMakeListsTxtAdvanced - cmakeListsTxtPath: "${{ github.workspace }}/CMakeLists.txt" - cmakeAppendedArgs: - buildDirectory: ${{ github.workspace }}/cmakebuild - buildWithCMakeArgs: "--config Release" - useVcpkgToolchainFile: false - + - name: Configure 5.12 + if: "contains( matrix.qtver, '5.12')" + run: | + cmake -S . -B build + + - name: Configure 6.5 + if: "contains( matrix.qtver, '6.5')" + run: | + cmake -S . -DUSE_QT6=TRUE -B build + + - name: Build + run: cmake --build build diff --git a/.gitignore b/.gitignore index dff97119..832aaace 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ plugins resources Doxygen.log *.swp +build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index a0ffc249..9f1e10a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.15) project(qwt) @@ -15,8 +15,16 @@ add_definitions(-DQWT_NO_SVG -DQWT_MOC_INCLUDE) include(src/CMakeLists.txt) -find_package(Qt5 COMPONENTS REQUIRED Concurrent Core Gui OpenGL PrintSupport Widgets) -set(QT_LIBRARIES Qt5::Concurrent Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::PrintSupport Qt5::Widgets) +option(USE_QT6 "Use Qt6" FALSE) + +if(USE_QT6) + find_package(Qt6 COMPONENTS REQUIRED Concurrent Core Gui OpenGLWidgets PrintSupport Widgets) + set(QT_LIBRARIES Qt6::Concurrent Qt6::Core Qt6::Gui Qt6::OpenGLWidgets Qt6::PrintSupport Qt6::Widgets) +else(USE_QT6) + find_package(Qt5 COMPONENTS REQUIRED Concurrent Core Gui OpenGL PrintSupport Widgets) + set(QT_LIBRARIES Qt5::Concurrent Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::PrintSupport Qt5::Widgets) +endif(USE_QT6) + set(CMAKE_AUTOMOC ON) add_library(${PROJECT_NAME} src/CMakeLists.txt ${HEADER_FILES} ${SOURCE_FILES} ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04b08b61..d0dbbfd8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.8.12) - set(HEADER_FILES ${HEADER_FILES} src/qwt.h src/qwt_abstract_scale_draw.h @@ -207,12 +205,10 @@ src/qwt_scale_widget.cpp) # QwtOpenGL set(HEADER_FILES ${HEADER_FILES} -src/qwt_plot_glcanvas.h src/qwt_plot_opengl_canvas.h ) set(SOURCE_FILES ${SOURCE_FILES} -src/qwt_plot_glcanvas.cpp src/qwt_plot_opengl_canvas.cpp )