refactor: Remove bar charts

This commit is contained in:
Lars Toenning
2024-06-03 22:00:19 +02:00
parent 3e40e4f838
commit 77de5c9336
10 changed files with 0 additions and 543 deletions

View File

@@ -139,7 +139,6 @@ endif()
# Add external folders
add_subdirectory(cmake/vatsimauth)
add_subdirectory(cmake/qwt_plot)
add_subdirectory(cmake/dbus)
add_subdirectory(cmake/sodium)
add_subdirectory(cmake/msgpack)

View File

@@ -1,30 +0,0 @@
# SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
# SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
add_library(externals_qwt_plot SHARED IMPORTED GLOBAL)
target_include_directories(externals_qwt_plot INTERFACE ${PROJECT_SOURCE_DIR}/third_party/externals/common/include/qwt)
if(UNIX AND NOT APPLE)
set_target_properties(externals_qwt_plot PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/third_party/externals/linux-g++/64/lib/libqwt.so)
elseif(APPLE)
set_target_properties(externals_qwt_plot PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/third_party/externals/macx-clang/64/lib/qwt.framework/qwt)
elseif(SWIFT_WIN32)
set_target_properties(externals_qwt_plot PROPERTIES IMPORTED_IMPLIB ${PROJECT_SOURCE_DIR}/third_party/externals/win32-msvc/32/lib/qwt.lib)
set_target_properties(externals_qwt_plot PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/third_party/externals/win32-msvc/32/lib/qwt.dll)
elseif(SWIFT_WIN64)
set_target_properties(externals_qwt_plot PROPERTIES IMPORTED_IMPLIB ${PROJECT_SOURCE_DIR}/third_party/externals/win32-msvc/64/lib/qwt.lib)
set_target_properties(externals_qwt_plot PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/third_party/externals/win32-msvc/64/lib/qwt.dll)
endif()
target_link_libraries(externals_qwt_plot INTERFACE Qt::OpenGL)
if(APPLE)
# Special handling for qwt.framework
install(DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/externals/macx-clang/64/lib/qwt.framework DESTINATION lib)
else()
install(IMPORTED_RUNTIME_ARTIFACTS externals_qwt_plot
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
endif()

View File

@@ -28,9 +28,6 @@
<allowWildcards>1</allowWildcards>
<origin>../../dist/bin/libsodium*.dll</origin>
</distributionFile>
<distributionFile>
<origin>../../dist/bin/qwt.dll</origin>
</distributionFile>
<distributionFile>
<allowWildcards>1</allowWildcards>
<origin>../../dist/bin/SimConnect*.dll</origin>
@@ -86,9 +83,6 @@
<distributionFile>
<origin>../../dist/lib/libvatsimauth.so</origin>
</distributionFile>
<distributionFile>
<origin>../../dist/lib/libqwt.so</origin>
</distributionFile>
<distributionFile>
<allowWildcards>1</allowWildcards>
<origin>../../dist/lib/libsodium.so.*</origin>
@@ -110,9 +104,6 @@
<distributionFile>
<origin>../../dist/lib/libvatsimauth.dylib</origin>
</distributionFile>
<distributionDirectory>
<origin>../../dist/lib/qwt.framework</origin>
</distributionDirectory>
</distributionFileList>
</folder>
</folderList>

View File

@@ -21,7 +21,6 @@
<li><a href="#qt">Qt5</a></li>
<li><a href="#speexdsp">SpeexDSP</a></li>
<li><a href="#vatlib">vatlib</a></li>
<li><a href="#qwt">Qwt</a></li>
<li><a href="#qtwebapp">QtWebApp</a></li>
</ul>
<h2 id="boost">Boost</h2>
@@ -664,47 +663,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/80x15.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
</pre>
<hr>
<h2 id="qwt">Qwt</h2>
<table>
<tr>
<td>Project website</td>
<td><a href="https://qwt.sourceforge.io/" target="_parent" title="https://qwt.sourceforge.io/" rel="nofollow">https://qwt.sourceforge.io/</a></td>
</tr>
<tr>
<td>Source code</td>
<td><a href="https://qwt.sourceforge.io/" target="_parent" title="https://qwt.sourceforge.io/" rel="nofollow">https://qwt.sourceforge.io/</a></td>
</tr>
</table>
<pre>
Qwt License
Version 1.0, January 1, 2003
The Qwt library and included programs are provided under the terms
of the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) with the following
exceptions:
1. Widgets that are subclassed from Qwt widgets do not
constitute a derivative work.
2. Static linking of applications and widgets to the
Qwt library does not constitute a derivative work
and does not require the author to provide source
code for the application or widget, use the shared
Qwt libraries, or link their applications or
widgets against a user-supplied version of Qwt.
If you link the application or widget to a modified
version of Qwt, then the changes to Qwt must be
provided under the terms of the LGPL in sections
1, 2, and 4.
3. You do not have to provide a copy of the Qwt license
with programs that are linked to the Qwt library, nor
do you have to identify the Qwt license in your
program or documentation as required by section 6
of the LGPL.
However, programs must still identify their use of Qwt.
The following example statement can be included in user
documentation to satisfy this requirement:
[program/widget] is based in part on the work of
the Qwt project (http://qwt.sf.net).
</pre>
<hr>
<h2 id="qtwebapp">QtWebApp</h2>
<table>
<tr>

View File

@@ -285,9 +285,6 @@ add_library(gui SHARED
loadindicator.h
pluginselector.h
infoarea.cpp
graphs
graphs/barchart.h
graphs/barchart.cpp
overlaymessagesframe.cpp
managedstatusbar.h
lineedithistory.cpp
@@ -944,11 +941,9 @@ target_link_libraries(gui
core
Qt::Widgets
Qt::Svg
externals_qwt_plot
)
target_compile_definitions(gui PRIVATE BUILD_BLACKGUI_LIB)
target_compile_definitions(gui PRIVATE QWT_DLL)
target_precompile_headers(gui
PRIVATE

View File

@@ -1,168 +0,0 @@
// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
#include "barchart.h"
#include <qwt_plot_renderer.h>
#include <qwt_plot_canvas.h>
#include <qwt_plot_multi_barchart.h>
#include <qwt_column_symbol.h>
#include <qwt_plot_layout.h>
#include <qwt_legend.h>
#include <qwt_scale_draw.h>
namespace BlackGui::Graphs
{
CBarChart::CBarChart(QWidget *parent) : QwtPlot(parent)
{
this->setAutoFillBackground(true);
this->setPalette(Qt::white);
this->canvas()->setPalette(QColor("LemonChiffon"));
this->setTitle("Bar Chart");
// setAxisTitle(QwtPlot::yLeft, "Whatever");
// setAxisTitle(QwtPlot::xBottom, "Whatever");
m_barChartItem.reset(new QwtPlotMultiBarChart("Bar Chart "));
m_barChartItem->setLayoutPolicy(QwtPlotMultiBarChart::AutoAdjustSamples);
m_barChartItem->setSpacing(5);
m_barChartItem->setMargin(3);
m_barChartItem->attach(this);
// this->insertLegend(new QwtLegend());
// this->setAutoReplot(true);
// this->setOrientation(Qt::Vertical);
}
void CBarChart::setStyle(QwtPlotMultiBarChart::ChartStyle style)
{
m_barChartItem->setStyle(style);
}
void CBarChart::setOrientation(Qt::Orientation orientation, const QStringList &labels)
{
QwtPlot::Axis axis1, axis2;
CTextScaleDraw *scaleDraw = labels.isEmpty() ? nullptr : new CTextScaleDraw(labels);
if (orientation == Qt::Vertical)
{
axis1 = QwtPlot::xBottom;
axis2 = QwtPlot::yLeft;
m_barChartItem->setOrientation(Qt::Vertical);
if (scaleDraw)
{
scaleDraw->setLabelRotation(90);
scaleDraw->setLabelAlignment(Qt::AlignRight);
}
}
else
{
axis1 = QwtPlot::yLeft;
axis2 = QwtPlot::xBottom;
m_barChartItem->setOrientation(Qt::Horizontal);
if (scaleDraw)
{
scaleDraw->setLabelRotation(0);
scaleDraw->setLabelAlignment(Qt::AlignLeft);
}
}
setAxisScale(axis1, 0, m_barChartItem->dataSize() - 1, 1.0);
setAxisAutoScale(axis2);
QwtScaleDraw *scaleDraw1 = axisScaleDraw(axis1);
scaleDraw1->enableComponent(QwtScaleDraw::Backbone, true);
scaleDraw1->enableComponent(QwtScaleDraw::Ticks, false);
QwtScaleDraw *scaleDraw2 = axisScaleDraw(axis2);
scaleDraw2->enableComponent(QwtScaleDraw::Backbone, true);
scaleDraw2->enableComponent(QwtScaleDraw::Ticks, false);
this->setAxisScaleDraw(axis1, scaleDraw ? scaleDraw : new QwtScaleDraw());
this->setAxisScaleDraw(axis2, new QwtScaleDraw());
plotLayout()->setAlignCanvasToScale(axis1, true);
plotLayout()->setAlignCanvasToScale(axis2, true);
plotLayout()->setCanvasMargin(0);
this->updateCanvasMargins();
this->replot();
}
void CBarChart::setSymbols(const QString &title, const QString &color)
{
const QStringList titles({ title });
const QStringList colors({ color });
this->setSymbols(titles, colors);
}
void CBarChart::setSymbols(const QStringList &titles, const QStringList &colors)
{
Q_ASSERT_X(!titles.isEmpty(), Q_FUNC_INFO, "Need titles");
Q_ASSERT_X(titles.size() == colors.size(), Q_FUNC_INFO, "Need same size");
int i = 0;
m_barChartItem->resetSymbolMap();
for (const QString &color : colors)
{
QwtColumnSymbol *symbol = new QwtColumnSymbol(QwtColumnSymbol::Box);
symbol->setLineWidth(2);
symbol->setFrameStyle(QwtColumnSymbol::Raised);
symbol->setPalette(QPalette(color));
m_barChartItem->setSymbol(i++, symbol);
}
QList<QwtText> qwtTitles;
for (const QString &title : titles)
{
qwtTitles << title;
}
m_barChartItem->setBarTitles(qwtTitles);
m_barChartItem->setLegendIconSize(QSize(10, 14));
}
void CBarChart::setSamples1Bar(const QList<double> &samples, const QStringList &labels, Qt::Orientation orientation)
{
QVector<QVector<double>> series;
for (double d : samples)
{
series << QVector<double> { d };
}
if (orientation == Qt::Vertical)
{
int w = samples.size() * 10;
if (w < 200) w = 200;
this->setMinimumWidth(w);
this->setMinimumHeight(0);
}
else
{
int h = samples.size() * 10;
if (h < 200) h = 200;
this->setMinimumHeight(h);
this->setMinimumWidth(0);
}
m_barChartItem->setSamples(series);
this->setOrientation(orientation, labels);
}
CTextScaleDraw::CTextScaleDraw(const QStringList &texts) : m_labels(texts)
{
this->setLabelRotation(0);
this->setLabelAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
this->setSpacing(5);
}
QwtText CTextScaleDraw::label(double v) const
{
if (m_labels.isEmpty()) { return QString::number(v); }
const int i = qRound(v);
if (i < 0 || m_labels.size() <= i) { return QwtText("invalid"); }
return m_labels.at(i);
}
} // ns

View File

@@ -1,72 +0,0 @@
// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
//! \file
#ifndef BLACKGUI_GRAPH_BARCHART_H
#define BLACKGUI_GRAPH_BARCHART_H
#include "blackgui/blackguiexport.h"
#include <qwt_plot.h>
#include <qwt_scale_draw.h>
#include <qwt_plot_multi_barchart.h>
#include <QScopedPointer>
#include <QStringList>
#include <QList>
namespace BlackGui::Graphs
{
/*!
* For axis labels
*/
class CTextScaleDraw : public QwtScaleDraw
{
public:
//! Constructorxs
CTextScaleDraw(const QStringList &texts);
//! Value to label
virtual QwtText label(double v) const override;
//! Labels
void setLabels(const QStringList &labels) { m_labels = labels; }
//! Any labels?
bool hasLabels() const { return !m_labels.isEmpty(); }
private:
QStringList m_labels;
};
/*!
* Bar chart, modified version of QWT examples
*/
class BLACKGUI_EXPORT CBarChart : public QwtPlot
{
public:
//! Constructor
CBarChart(QWidget * = nullptr);
//! Style
void setStyle(QwtPlotMultiBarChart::ChartStyle style);
//! Set number of symbols
void setSymbols(const QString &title, const QString &color);
//! Set number of symbols
void setSymbols(const QStringList &titles, const QStringList &colors);
//! Samples with 1 bar per sample
void setSamples1Bar(const QList<double> &samples, const QStringList &labels, Qt::Orientation orientation);
private:
//! Orientation
void setOrientation(Qt::Orientation, const QStringList &labels);
QScopedPointer<QwtPlotMultiBarChart> m_barChartItem;
};
} // ns
#endif

View File

@@ -27,7 +27,6 @@ namespace BlackGui::Views
this->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(ui->pb_GenerateMatrix, &QPushButton::released, this, &CAircraftModelStatisticsDialog::displayHTMLMatrix);
connect(ui->pb_ShowChart, &QPushButton::released, this, &CAircraftModelStatisticsDialog::showChart);
}
CAircraftModelStatisticsDialog::~CAircraftModelStatisticsDialog()
@@ -45,75 +44,4 @@ namespace BlackGui::Views
if (file.isEmpty()) { return; }
QDesktopServices::openUrl(QUrl::fromLocalFile(file));
}
void CAircraftModelStatisticsDialog::showChart()
{
if (ui->rb_Distributors->isChecked())
{
this->chartDistributors();
return;
}
if (ui->rb_AircraftIcao->isChecked())
{
this->chartAircraftIcao();
return;
}
}
void CAircraftModelStatisticsDialog::chartDistributors()
{
const QMap<CDistributor, int> distributors = m_models.countPerDistributor();
QStringList distributorsForAxis;
QList<double> series;
CDistributorList distributorList(distributors.keys());
distributorList.sortByKey();
for (const CDistributor &distributor : std::as_const(distributorList))
{
const int c = distributors[distributor];
if (c < 1) { continue; }
distributorsForAxis << (distributor.getDbKey() % u" (" % QString::number(c) % u")");
series << c;
}
QwtText title("distributor");
title.setRenderFlags(Qt::AlignLeft);
ui->qwt_Chart->setSymbols("distributors", "white");
ui->qwt_Chart->setTitle(title);
ui->qwt_Chart->setSamples1Bar(series, distributorsForAxis, this->getOrientation());
}
void CAircraftModelStatisticsDialog::chartAircraftIcao()
{
const QMap<CAircraftIcaoCode, int> icaos = m_models.countPerAircraftIcao();
QStringList icaosForAxis;
QList<double> series;
CAircraftIcaoCodeList icaoList(icaos.keys());
icaoList.sortByDesignatorAndRank();
for (const CAircraftIcaoCode &icao : std::as_const(icaoList))
{
const int c = icaos[icao];
if (c < 1) { continue; }
if (!icao.hasKnownDesignator())
{
continue;
}
icaosForAxis << (icao.getDesignatorDbKey() % u" (" % QString::number(c) % u")");
series << c;
}
QwtText title("aircraft ICAO");
title.setRenderFlags(Qt::AlignLeft);
ui->qwt_Chart->setSymbols("aircraft", "white");
ui->qwt_Chart->setTitle(title);
ui->qwt_Chart->setSamples1Bar(series, icaosForAxis, this->getOrientation());
}
Qt::Orientation CAircraftModelStatisticsDialog::getOrientation() const
{
return ui->rb_Vertical->isChecked() ? Qt::Vertical : Qt::Horizontal;
}
} // ns

View File

@@ -40,18 +40,6 @@ namespace BlackGui::Views
//! Display the HTML matrix
void displayHTMLMatrix();
//! Chart
void showChart();
//! Chart for distributors
void chartDistributors();
//! Chart for aircraft ICAO
void chartAircraftIcao();
//! Orientation
Qt::Orientation getOrientation() const;
QScopedPointer<Ui::CAircraftModelStatisticsDialog> ui;
BlackMisc::Simulation::CAircraftModelList m_models;
};

View File

@@ -42,132 +42,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_Charts">
<attribute name="title">
<string>Charts</string>
</attribute>
<layout class="QVBoxLayout" name="vl_Charts" stretch="0,0">
<item>
<widget class="QFrame" name="fr_ChartType">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<layout class="QHBoxLayout" name="hl_ChartType">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QRadioButton" name="rb_Distributors">
<property name="text">
<string>distributors</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_Chart</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_AircraftIcao">
<property name="text">
<string>aircraft</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_Chart</string>
</attribute>
</widget>
</item>
<item>
<spacer name="hs_ChartType">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="rb_Horizontal">
<property name="text">
<string>horizontal</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_Layout</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_Vertical">
<property name="text">
<string>vertical</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_Layout</string>
</attribute>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_ShowChart">
<property name="text">
<string>show</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QScrollArea" name="sa_Chart">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="sa_ChartContent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>161</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="BlackGui::Graphs::CBarChart" name="qwt_Chart">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_Matrix">
<attribute name="title">
<string>Matrix</string>
@@ -204,12 +78,6 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Graphs::CBarChart</class>
<extends>QFrame</extends>
<header>blackgui/graphs/barchart.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>