Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Qt6 #4

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ plugins
resources
Doxygen.log
*.swp
build
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.15)

project(qwt)

Expand All @@ -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} )
Expand Down
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
)

Expand Down
7 changes: 4 additions & 3 deletions src/qwt_plot_axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] |=
Expand Down Expand Up @@ -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() ) );
Expand Down
17 changes: 16 additions & 1 deletion src/qwt_plot_curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,20 +786,32 @@ 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 );

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 );
}

Expand Down Expand Up @@ -1055,6 +1067,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() );
Expand Down