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

添加qwt对qt6的支持 #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
215 changes: 215 additions & 0 deletions third/3rd_qwt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Concurrent PrintSupport REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Concurrent PrintSupport REQUIRED)

add_definitions(-DQWT_NO_SVG -DQWT_NO_OPENGL)

set(PUBLIC_HEADERS
qwt.h
qwt_abstract_legend.h
qwt_abstract_scale.h
qwt_abstract_scale_draw.h
qwt_abstract_slider.h
qwt_analog_clock.h
qwt_arrow_button.h
qwt_clipper.h
qwt_color_map.h
qwt_column_symbol.h
qwt_compass.h
qwt_compass_rose.h
qwt_compat.h
qwt_counter.h
qwt_curve_fitter.h
qwt_date.h
qwt_date_scale_draw.h
qwt_date_scale_engine.h
qwt_dial.h
qwt_dial_needle.h
qwt_dyngrid_layout.h
qwt_event_pattern.h
qwt_global.h
qwt_graphic.h
qwt_interval.h
qwt_interval_symbol.h
qwt_knob.h
qwt_legend.h
qwt_legend_data.h
qwt_legend_label.h
qwt_magnifier.h
qwt_math.h
qwt_matrix_raster_data.h
qwt_null_paintdevice.h
qwt_painter.h
qwt_painter_command.h
qwt_panner.h
qwt_picker.h
qwt_picker_machine.h
qwt_pixel_matrix.h
qwt_plot.h
qwt_plot_abstract_barchart.h
qwt_plot_barchart.h
qwt_plot_canvas.h
qwt_plot_curve.h
qwt_plot_dict.h
qwt_plot_directpainter.h
qwt_plot_grid.h
qwt_plot_histogram.h
qwt_plot_intervalcurve.h
qwt_plot_item.h
qwt_plot_layout.h
qwt_plot_legenditem.h
qwt_plot_magnifier.h
qwt_plot_marker.h
qwt_plot_multi_barchart.h
qwt_plot_panner.h
qwt_plot_picker.h
qwt_plot_rasteritem.h
qwt_plot_renderer.h
qwt_plot_rescaler.h
qwt_plot_scaleitem.h
qwt_plot_seriesitem.h
qwt_plot_shapeitem.h
qwt_plot_spectrocurve.h
qwt_plot_spectrogram.h
qwt_plot_textlabel.h
qwt_plot_tradingcurve.h
qwt_plot_zoneitem.h
qwt_plot_zoomer.h
qwt_point_3d.h
qwt_point_data.h
qwt_point_mapper.h
qwt_point_polar.h
qwt_raster_data.h
qwt_round_scale_draw.h
qwt_samples.h
qwt_sampling_thread.h
qwt_scale_div.h
qwt_scale_draw.h
qwt_scale_engine.h
qwt_scale_map.h
qwt_scale_widget.h
qwt_series_data.h
qwt_series_store.h
qwt_slider.h
qwt_spline.h
qwt_symbol.h
qwt_system_clock.h
qwt_text.h
qwt_text_engine.h
qwt_text_label.h
qwt_thermo.h
qwt_transform.h
qwt_wheel.h
qwt_widget_overlay.h
)

source_group("Public API" FILES ${PUBLIC_HEADERS})

set(QWTD_SOURCES
qwt_abstract_legend.cpp
qwt_abstract_scale.cpp
qwt_abstract_scale_draw.cpp
qwt_abstract_slider.cpp
qwt_analog_clock.cpp
qwt_arrow_button.cpp
qwt_clipper.cpp
qwt_color_map.cpp
qwt_column_symbol.cpp
qwt_compass.cpp
qwt_compass_rose.cpp
qwt_counter.cpp
qwt_curve_fitter.cpp
qwt_date.cpp
qwt_date_scale_draw.cpp
qwt_date_scale_engine.cpp
qwt_dial.cpp
qwt_dial_needle.cpp
qwt_dyngrid_layout.cpp
qwt_event_pattern.cpp
qwt_graphic.cpp
qwt_interval.cpp
qwt_interval_symbol.cpp
qwt_knob.cpp
qwt_legend.cpp
qwt_legend_data.cpp
qwt_legend_label.cpp
qwt_magnifier.cpp
qwt_math.cpp
qwt_matrix_raster_data.cpp
qwt_null_paintdevice.cpp
qwt_painter.cpp
qwt_painter_command.cpp
qwt_panner.cpp
qwt_picker.cpp
qwt_picker_machine.cpp
qwt_pixel_matrix.cpp
qwt_plot.cpp
qwt_plot_abstract_barchart.cpp
qwt_plot_axis.cpp
qwt_plot_barchart.cpp
qwt_plot_canvas.cpp
qwt_plot_curve.cpp
qwt_plot_dict.cpp
qwt_plot_directpainter.cpp
qwt_plot_grid.cpp
qwt_plot_histogram.cpp
qwt_plot_intervalcurve.cpp
qwt_plot_item.cpp
qwt_plot_layout.cpp
qwt_plot_legenditem.cpp
qwt_plot_magnifier.cpp
qwt_plot_marker.cpp
qwt_plot_multi_barchart.cpp
qwt_plot_panner.cpp
qwt_plot_picker.cpp
qwt_plot_rasteritem.cpp
qwt_plot_renderer.cpp
qwt_plot_rescaler.cpp
qwt_plot_scaleitem.cpp
qwt_plot_seriesitem.cpp
qwt_plot_shapeitem.cpp
qwt_plot_spectrocurve.cpp
qwt_plot_spectrogram.cpp
qwt_plot_textlabel.cpp
qwt_plot_tradingcurve.cpp
qwt_plot_xml.cpp
qwt_plot_zoneitem.cpp
qwt_plot_zoomer.cpp
qwt_point_3d.cpp
qwt_point_data.cpp
qwt_point_mapper.cpp
qwt_point_polar.cpp
qwt_raster_data.cpp
qwt_round_scale_draw.cpp
qwt_sampling_thread.cpp
qwt_scale_div.cpp
qwt_scale_draw.cpp
qwt_scale_engine.cpp
qwt_scale_map.cpp
qwt_scale_widget.cpp
qwt_series_data.cpp
qwt_slider.cpp
qwt_spline.cpp
qwt_symbol.cpp
qwt_system_clock.cpp
qwt_text.cpp
qwt_text_engine.cpp
qwt_text_label.cpp
qwt_thermo.cpp
qwt_transform.cpp
qwt_wheel.cpp
qwt_widget_overlay.cpp
)

add_library(qwtd STATIC ${PUBLIC_HEADERS} ${QWTD_SOURCES})

target_link_libraries(
qwtd
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::PrintSupport
)

target_include_directories(qwtd
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
5 changes: 3 additions & 2 deletions third/3rd_qwt/qwt_abstract_slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,13 @@ void QwtAbstractSlider::wheelEvent( QWheelEvent *event )
{
// one page regardless of delta
numSteps = d_data->pageSteps;
if ( event->delta() < 0 )
if ( event->angleDelta().y() < 0.0 ) {
numSteps = -numSteps;
}
}
else
{
const int numTurns = ( event->delta() / 120 );
const int numTurns = ( event->angleDelta().y() / 120 );
numSteps = numTurns * d_data->singleSteps;
}

Expand Down
4 changes: 2 additions & 2 deletions third/3rd_qwt/qwt_analog_clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ QwtAnalogClock::QwtAnalogClock( QWidget *parent ):
setScale( scaleDiv );

QColor knobColor = palette().color( QPalette::Active, QPalette::Text );
knobColor = knobColor.dark( 120 );
knobColor = knobColor.darker( 120 );

QColor handColor;
int width;
Expand All @@ -82,7 +82,7 @@ QwtAnalogClock::QwtAnalogClock( QWidget *parent ):
if ( i == SecondHand )
{
width = 2;
handColor = knobColor.dark( 120 );
handColor = knobColor.darker( 120 );
}
else
{
Expand Down
11 changes: 8 additions & 3 deletions third/3rd_qwt/qwt_arrow_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class QwtArrowButton::PrivateData
static QStyleOptionButton styleOpt( const QwtArrowButton* btn )
{
QStyleOptionButton option;
option.init( btn );
option.initFrom( btn );
option.features = QStyleOptionButton::None;
if ( btn->isFlat() )
option.features |= QStyleOptionButton::Flat;
Expand Down Expand Up @@ -198,7 +198,7 @@ void QwtArrowButton::drawButtonLabel( QPainter *painter )
if ( hasFocus() )
{
QStyleOptionFocusRect option;
option.init( this );
option.initFrom( this );
option.backgroundColor = palette().color( QPalette::Window );

style()->drawPrimitive( QStyle::PE_FrameFocusRect,
Expand Down Expand Up @@ -260,7 +260,12 @@ void QwtArrowButton::drawArrow( QPainter *painter,
QSize QwtArrowButton::sizeHint() const
{
const QSize hint = minimumSizeHint();
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
return hint.expandedTo( QApplication::globalStrut() );
#else
QScreen *screen = QGuiApplication::primaryScreen();
return hint.expandedTo( screen->availableSize() );
#endif
}

/*!
Expand All @@ -279,7 +284,7 @@ QSize QwtArrowButton::minimumSizeHint() const
sz.transpose();

QStyleOption styleOption;
styleOption.init( this );
styleOption.initFrom( this );

sz = style()->sizeFromContents( QStyle::CT_PushButton,
&styleOption, sz, this );
Expand Down
4 changes: 3 additions & 1 deletion third/3rd_qwt/qwt_clipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <qrect.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>

#if QT_VERSION < 0x040601
#define qAtan(x) ::atan(x)
Expand Down Expand Up @@ -351,7 +353,7 @@ QVector<QwtInterval> QwtCircleClipper::clipCircle(
QList<double> angles;
for ( int i = 0; i < points.size(); i++ )
angles += toAngle( pos, points[i] );
qSort( angles );
std::sort(angles.begin(), angles.end());

const int in = d_rect.contains( qwtPolar2Pos( pos, radius,
angles[0] + ( angles[1] - angles[0] ) / 2 ) );
Expand Down
7 changes: 6 additions & 1 deletion third/3rd_qwt/qwt_compass_rose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ static QPointF qwtIntersection(
const QLineF line2( p21, p22 );

QPointF pos;
if ( line1.intersect( line2, &pos ) == QLineF::NoIntersection )
#if (QT_VERSION < QT_VERSION_CHECK(5,14,0))
if ( line1.intersect( line2, &pos ) == QLineF::NoIntersection ) {
#else
if ( line1.intersects( line2, &pos ) == QLineF::NoIntersection ) {
#endif
return QPointF();
}

return pos;
}
Expand Down
20 changes: 19 additions & 1 deletion third/3rd_qwt/qwt_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ void QwtCounter::initCounter()

QHBoxLayout *layout = new QHBoxLayout( this );
layout->setSpacing( 0 );
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
layout->setMargin( 0 );
#else
layout->setContentsMargins(0, 0, 0, 0);
#endif

for ( int i = ButtonCnt - 1; i >= 0; i-- )
{
Expand Down Expand Up @@ -486,7 +490,11 @@ bool QwtCounter::event( QEvent *event )
{
if ( event->type() == QEvent::PolishRequest )
{
#if (QT_VERSION < QT_VERSION_CHECK(5,11,0))
const int w = d_data->valueEdit->fontMetrics().width( "W" ) + 8;
#else
const int w = d_data->valueEdit->fontMetrics().horizontalAdvance( "W" ) + 8;
#endif
for ( int i = 0; i < ButtonCnt; i++ )
{
d_data->buttonDown[i]->setMinimumWidth( w );
Expand Down Expand Up @@ -607,8 +615,13 @@ void QwtCounter::wheelEvent( QWheelEvent *event )

for ( int i = 0; i < d_data->numButtons; i++ )
{
#if (QT_VERSION < QT_VERSION_CHECK(5,15,0))
if ( d_data->buttonDown[i]->geometry().contains( event->pos() ) ||
d_data->buttonUp[i]->geometry().contains( event->pos() ) )
#else
if ( d_data->buttonDown[i]->geometry().contains( event->position().toPoint() ) ||
d_data->buttonUp[i]->geometry().contains( event->position().toPoint() ) )
#endif
{
increment = d_data->increment[i];
}
Expand All @@ -617,7 +630,8 @@ void QwtCounter::wheelEvent( QWheelEvent *event )
const int wheel_delta = 120;

#if 1
int delta = event->delta();
int delta = event->angleDelta().y();

if ( delta >= 2 * wheel_delta )
delta /= 2; // Never saw an abs(delta) < 240
#endif
Expand Down Expand Up @@ -769,7 +783,11 @@ QSize QwtCounter::sizeHint() const
tmp.fill( '9', w );

QFontMetrics fm( d_data->valueEdit->font() );
#if (QT_VERSION < QT_VERSION_CHECK(5,11,0))
w = fm.width( tmp ) + 2;
#else
w = fm.horizontalAdvance( tmp ) + 2;
#endif
if ( d_data->valueEdit->hasFrame() )
w += 2 * style()->pixelMetric( QStyle::PM_DefaultFrameWidth );

Expand Down
2 changes: 1 addition & 1 deletion third/3rd_qwt/qwt_date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ int QwtDate::utcOffset( const QDateTime &dateTime )
}
case Qt::OffsetFromUTC:
{
seconds = dateTime.utcOffset();
seconds = dateTime.offsetFromUtc();
break;
}
default:
Expand Down
Loading