2024-08-21 18:06:30 +01:00
|
|
|
#ifndef WILDMONCHART_H
|
|
|
|
#define WILDMONCHART_H
|
|
|
|
|
|
|
|
#include "encountertablemodel.h"
|
|
|
|
|
|
|
|
#include <QWidget>
|
2024-08-22 07:09:28 +01:00
|
|
|
#include <QtCharts>
|
2024-08-21 18:06:30 +01:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class WildMonChart;
|
|
|
|
}
|
|
|
|
|
|
|
|
class WildMonChart : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2024-08-22 04:28:33 +01:00
|
|
|
explicit WildMonChart(QWidget *parent, const EncounterTableModel *table);
|
2024-08-21 18:06:30 +01:00
|
|
|
~WildMonChart();
|
|
|
|
|
2024-08-23 21:00:42 +01:00
|
|
|
virtual void closeEvent(QCloseEvent *event) override;
|
|
|
|
|
2024-08-21 18:06:30 +01:00
|
|
|
public slots:
|
2024-08-22 04:28:33 +01:00
|
|
|
void setTable(const EncounterTableModel *table);
|
2024-08-27 04:53:08 +01:00
|
|
|
void clearTable();
|
|
|
|
void refresh();
|
2024-08-21 18:06:30 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::WildMonChart *ui;
|
2024-08-22 04:28:33 +01:00
|
|
|
const EncounterTableModel *table;
|
2024-08-22 07:09:28 +01:00
|
|
|
|
|
|
|
QStringList groupNames;
|
2024-08-23 20:00:00 +01:00
|
|
|
QStringList groupNamesReversed;
|
|
|
|
QStringList speciesInLegendOrder;
|
2024-08-22 07:09:28 +01:00
|
|
|
QMap<int, QString> tableIndexToGroupName;
|
|
|
|
|
2024-08-23 17:06:50 +01:00
|
|
|
struct LevelRange {
|
|
|
|
int min;
|
|
|
|
int max;
|
|
|
|
};
|
|
|
|
QMap<QString, LevelRange> groupedLevelRanges;
|
|
|
|
|
2024-08-22 07:09:28 +01:00
|
|
|
struct Summary {
|
|
|
|
double speciesFrequency = 0.0;
|
|
|
|
QMap<int, double> levelFrequencies;
|
|
|
|
};
|
|
|
|
typedef QMap<QString, Summary> GroupedData;
|
|
|
|
|
|
|
|
QMap<QString, GroupedData> speciesToGroupedData;
|
2024-08-23 18:15:48 +01:00
|
|
|
QMap<QString, QColor> speciesToColor;
|
|
|
|
|
2024-08-22 07:09:28 +01:00
|
|
|
|
2024-08-23 20:00:00 +01:00
|
|
|
QStringList getSpeciesNamesAlphabetical() const;
|
2024-08-22 07:09:28 +01:00
|
|
|
double getSpeciesFrequency(const QString&, const QString&) const;
|
|
|
|
QMap<int, double> getLevelFrequencies(const QString &, const QString &) const;
|
2024-08-23 18:15:48 +01:00
|
|
|
LevelRange getLevelRange(const QString &, const QString &) const;
|
2024-08-22 07:09:28 +01:00
|
|
|
bool usesGroupLabels() const;
|
|
|
|
|
|
|
|
void clearTableData();
|
|
|
|
void readTable();
|
2024-08-27 04:53:08 +01:00
|
|
|
QChart* createSpeciesDistributionChart();
|
|
|
|
QChart* createLevelDistributionChart();
|
2024-08-24 04:59:54 +01:00
|
|
|
QBarSet* createLevelDistributionBarSet(const QString &, const QString &, bool);
|
2024-08-27 04:53:08 +01:00
|
|
|
void refreshSpeciesDistributionChart();
|
|
|
|
void refreshLevelDistributionChart();
|
2024-08-22 07:09:28 +01:00
|
|
|
|
2024-08-24 04:59:54 +01:00
|
|
|
void saveSpeciesColors(const QList<QBarSet*> &);
|
|
|
|
void applySpeciesColors(const QList<QBarSet*> &);
|
2024-08-23 18:15:48 +01:00
|
|
|
QChart::ChartTheme currentTheme() const;
|
|
|
|
void updateTheme();
|
2024-08-27 23:20:29 +01:00
|
|
|
void limitChartAnimation(QChart*);
|
2024-08-23 21:32:37 +01:00
|
|
|
|
|
|
|
void showHelpDialog();
|
2024-08-21 18:06:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WILDMONCHART_H
|