Skip to content

Commit

Permalink
OMPlot: Qt6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Apr 3, 2024
1 parent 1f30921 commit 602f82f
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions OMNotebook/OMNotebook/OMNotebookGUI/commandcompletion.h
Expand Up @@ -47,6 +47,7 @@
#include <QtCore/QStringList>
#include <QtGui/QTextCursor>
#include <QtXml/QDomDocument>
#include <QRegularExpression>

//IAEX Headers
#include "commandunit.h"
Expand Down
6 changes: 5 additions & 1 deletion OMPlot/CMakeLists.txt
Expand Up @@ -10,7 +10,11 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)


find_package(Qt5 COMPONENTS Widgets PrintSupport REQUIRED)
find_package(Qt${OM_QT_MAJOR_VERSION} COMPONENTS Widgets PrintSupport REQUIRED)

if (OM_QT_MAJOR_VERSION VERSION_GREATER_EQUAL 6)
find_package(Qt6 COMPONENTS Core5Compat REQUIRED)
endif ()

omc_add_subdirectory(qwt)
omc_add_subdirectory(OMPlot/OMPlotGUI)
9 changes: 7 additions & 2 deletions OMPlot/OMPlot/OMPlotGUI/CMakeLists.txt
Expand Up @@ -40,8 +40,13 @@ endif()

target_include_directories(OMPlotLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(OMPlotLib PUBLIC Qt5::Widgets)
target_link_libraries(OMPlotLib PUBLIC Qt5::PrintSupport)
target_link_libraries(OMPlotLib PUBLIC Qt${OM_QT_MAJOR_VERSION}::Widgets)
target_link_libraries(OMPlotLib PUBLIC Qt${OM_QT_MAJOR_VERSION}::PrintSupport)

if (OM_QT_MAJOR_VERSION VERSION_GREATER_EQUAL 6)
target_link_libraries(OMPlotLib PUBLIC Qt6::Core5Compat)
endif ()

target_link_libraries(OMPlotLib PUBLIC omqwt)
target_link_libraries(OMPlotLib PUBLIC omc::simrt::runtime)

Expand Down
1 change: 1 addition & 0 deletions OMPlot/OMPlot/OMPlotGUI/LinearScaleEngine.cpp
Expand Up @@ -33,6 +33,7 @@
*/

#include "LinearScaleEngine.h"
#include "qwt_interval.h"

using namespace OMPlot;

Expand Down
12 changes: 8 additions & 4 deletions OMPlot/OMPlot/OMPlotGUI/LogScaleEngine.cpp
Expand Up @@ -36,6 +36,10 @@
#include "LinearScaleEngine.h"

#include "qwt_math.h"
#include "qwt_interval.h"
#include "qwt_transform.h"

#include <QtMath>

using namespace OMPlot;

Expand Down Expand Up @@ -91,7 +95,7 @@ void LogScaleEngine::autoScale(int maxNumSteps, double &x1, double &x2, double &
linearScaler.autoScale( maxNumSteps, x1, x2, stepSize );

QwtInterval linearInterval = QwtInterval( x1, x2 ).normalized();
linearInterval = linearInterval.limited( LOG_MIN, LOG_MAX );
linearInterval = linearInterval.limited(QwtLogTransform::LogMin, QwtLogTransform::LogMax);

if ( linearInterval.maxValue() / linearInterval.minValue() < logBase )
{
Expand All @@ -112,8 +116,8 @@ void LogScaleEngine::autoScale(int maxNumSteps, double &x1, double &x2, double &
}

double logRef = 1.0;
if ( reference() > LOG_MIN / 2 )
logRef = qMin( reference(), LOG_MAX / 2 );
if (reference() > QwtLogTransform::LogMin / 2)
logRef = qMin(reference(), QwtLogTransform::LogMax / 2);

if ( testAttribute( QwtScaleEngine::Symmetric ) )
{
Expand All @@ -124,7 +128,7 @@ void LogScaleEngine::autoScale(int maxNumSteps, double &x1, double &x2, double &
if ( testAttribute( QwtScaleEngine::IncludeReference ) )
interval = interval.extend( logRef );

interval = interval.limited( LOG_MIN, LOG_MAX );
interval = interval.limited(QwtLogTransform::LogMin, QwtLogTransform::LogMax);

if ( interval.width() == 0.0 || LinearScaleEngine::fuzzyCompare(interval.minValue(), interval.maxValue()) ) {
interval = buildInterval( interval.minValue() );
Expand Down
2 changes: 2 additions & 0 deletions OMPlot/OMPlot/OMPlotGUI/PlotCurve.cpp
Expand Up @@ -36,6 +36,8 @@
#include "qwt_painter.h"
#endif
#include "qwt_symbol.h"
#include "qwt_scale_map.h"
#include "qwt_point_polar.h"

using namespace OMPlot;

Expand Down
2 changes: 2 additions & 0 deletions OMPlot/OMPlot/OMPlotGUI/PlotGrid.h
Expand Up @@ -34,6 +34,8 @@

#include "OMPlot.h"

#include <QPen>

namespace OMPlot
{
class PlotGrid : public QwtPlotGrid
Expand Down
1 change: 1 addition & 0 deletions OMPlot/OMPlot/OMPlotGUI/PlotPicker.cpp
Expand Up @@ -36,6 +36,7 @@
#include "qwt_symbol.h"

#include <QToolTip>
#include <QtMath>

using namespace OMPlot;

Expand Down
7 changes: 7 additions & 0 deletions OMPlot/OMPlot/OMPlotGUI/PlotWindow.cpp
Expand Up @@ -52,8 +52,11 @@
#include <QDir>
#include <QMessageBox>
#include <QFileDialog>
#include <QPainter>
#include <QPrinter>
#include <QPrintDialog>
#include <QRegExp>
#include <QStack>
#include <QLineEdit>
#include <QColorDialog>

Expand All @@ -64,7 +67,11 @@ PlotWindow::PlotWindow(QStringList arguments, QWidget *parent, bool isInteractiv
{
/* set the widget background white. so that the plot is more useable in books and publications. */
QPalette p(palette());
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
p.setColor(QPalette::Window, Qt::white);
#else
p.setColor(QPalette::Background, Qt::white);
#endif
setAutoFillBackground(true);
setPalette(p);
// setup the main window widget
Expand Down
5 changes: 5 additions & 0 deletions OMPlot/OMPlot/OMPlotGUI/PlotWindow.h
Expand Up @@ -52,6 +52,7 @@
#include <QDoubleSpinBox>
#include <QDialog>
#include <QStackedWidget>
#include <QTextStream>
#include <QDialogButtonBox>

#include <qwt_plot.h>
Expand All @@ -67,7 +68,11 @@
#include <qwt_plot_panner.h>
#include <qwt_scale_engine.h>
#if QWT_VERSION >= 0x060000
#if QWT_VERSION < 0x060200
#include <qwt_compat.h>
#else
#define QwtArray QVector
#endif
#endif
#include <stdexcept>
#include "util/read_matlab4.h"
Expand Down

0 comments on commit 602f82f

Please sign in to comment.