DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
statscontroller.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
3 // AND EFFORT DISPLACEMENT
4 // Copyright (c) 2012-2019 Francois Bastardie <fba@aqua.dtu.dk>
5 
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // --------------------------------------------------------------------------
20 
21 
22 #ifndef STATSCONTROLLER_H
23 #define STATSCONTROLLER_H
24 
25 #include <QObject>
26 #include <qcustomplot.h>
27 #include <palettemanager.h>
28 
29 #include "plottypes.h"
31 #include <StatsPlot.h>
32 
33 class DisplaceModel;
34 class BenthosStatsPlot;
35 class FishfarmsStatsPlot;
36 class WindfarmsStatsPlot;
37 class ShipsStatsPlot;
38 class NationsStatsPlot;
39 class VesselsStatsPlot;
41 class HarboursStatPlot;
42 class MetiersStatsPlot;
43 class PlotWidget;
44 
45 class StatsController : public QObject
46 {
47  Q_OBJECT
48 public:
49  explicit StatsController(QObject *parent = 0);
50 
52  void setHarboursPlot(PlotWidget *plot);
53  void setMetiersPlot(PlotWidget *plot);
54  void setBenthosPlot(PlotWidget *plot, GraphInteractionController *controller);
55  void setFishfarmsPlot(PlotWidget *plot, GraphInteractionController *controller = nullptr);
56  void setWindfarmsPlot(PlotWidget *plot, GraphInteractionController *controller = nullptr);
57  void setShipsPlot(PlotWidget *plot, GraphInteractionController *controller = nullptr);
58  void setNationsStatsPlot(PlotWidget *plot, GraphInteractionController *controller = nullptr);
59  void setVesselsStatsPlot(PlotWidget *plot, GraphInteractionController *controller = nullptr);
60 
61  void updateStats(DisplaceModel *model);
62 
63  enum StatType {
65  };
66 
68  displace::plot::PopulationStat getPopulationStat() const { return mSelectedPopStat; }
69 
71  displace::plot::NationsStat getNationsStat() const { return mSelectedNationsStat; }
72 
74  displace::plot::VesselsStat getVesselsStat() const { return mSelectedVesselsStat; }
75 
77  displace::plot::HarboursStat getHarboursStat() const { return mSelectedHarboursStat; }
78 
80  displace::plot::MetiersStat getMetiersStat() const { return mSelectedMetiersStat; }
81 
83  displace::plot::BenthosStat getBenthosStat() const { return mSelectedBenthosStat; }
84 
86  displace::plot::FishfarmsStat getFishfarmsStat() const { return mSelectedFishfarmsStat; }
87 
89  displace::plot::WindfarmsStat getWindfarmsStat() const { return mSelectedWindfarmsStat; }
90 
92  displace::plot::ShipsStat getShipsStat() const { return mSelectedShipsStat; }
93 
94  /* == */
95 
96  void setCurrentTimeStep(double t);
97 
98  void plotGraph (DisplaceModel *model, StatType st, int subtype, QCustomPlot *plot = nullptr);
99 
100 protected:
102  void updateNationStats(DisplaceModel *model, displace::plot::NationsStat mSelectedNationsStat,
103  QCustomPlot *plot);
104  void updateVesselStats(DisplaceModel *model, displace::plot::VesselsStat mSelectedVesselsStat,
105  QCustomPlot *plot);
112 
113 private:
114  Palette mPalette;
115 
116  /* Populations stuff */
117  displace::plot::PopulationStat mSelectedPopStat;
118  PopulationsStatPlot *mPopPlot;
119 
120  /* Harbour stuff */
121  displace::plot::HarboursStat mSelectedHarboursStat;
122  HarboursStatPlot *mPlotHarbours;
123 
124  /* Nations */
125  QCustomPlot *mNationsPlot;
126  displace::plot::NationsStat mSelectedNationsStat;
127  QCPItemLine *mNatTimeLine;
128  NationsStatsPlot *mNationsStatsPlotController = nullptr;
129 
130  /* Vessels */
131  QCustomPlot *mVesselsPlot;
132  displace::plot::VesselsStat mSelectedVesselsStat;
133  QCPItemLine *mVesTimeLine;
134  VesselsStatsPlot *mVesselsStatsPlotController = nullptr;
135 
136  /* Metiers */
138  MetiersStatsPlot *mPlotMetiers;
139 
140  /* Benthos Functional Groups */
141  QCustomPlot *mBenthosFuncGroupsPlot = nullptr;
143  QCPItemLine *mBenthosTimeLine = nullptr;
144  BenthosStatsPlot *mBenthosPlotController = nullptr;
145 
146  /* Fishfarm farmtype Groups */
147  QCustomPlot *mfarmTypeGroupsPlot = nullptr;
149  QCPItemLine *mFishfarmsTimeLine = nullptr;
150  FishfarmsStatsPlot *mFishfarmsPlotController = nullptr;
151 
152  /* Windfarm farmtype Groups */
153  QCustomPlot *mWindfarmTypeGroupsPlot = nullptr;
155  QCPItemLine *mWindfarmsTimeLine = nullptr;
156  WindfarmsStatsPlot *mWindfarmsPlotController = nullptr;
157 
158  /* Ship farmtype Groups */
159  QCustomPlot *mShipTypeGroupsPlot = nullptr;
161  QCPItemLine *mShipsTimeLine = nullptr;
162  ShipsStatsPlot *mShipsPlotController = nullptr;
163 
164 
165  DisplaceModel *mLastModel;
166 
167  static double timelineMin, timelineMax;
168 };
169 
170 #endif // STATSCONTROLLER_H
void setNationsStatsPlot(PlotWidget *plot, GraphInteractionController *controller=nullptr)
Definition: statscontroller.cpp:165
StatsController(QObject *parent=0)
Definition: statscontroller.cpp:42
void updateStats(DisplaceModel *model)
Definition: statscontroller.cpp:192
VesselsStat
Definition: plottypes.h:20
displace::plot::VesselsStat getVesselsStat() const
Definition: statscontroller.h:74
WindfarmsStat
Definition: plottypes.h:13
void updateMetiersStats(DisplaceModel *model, displace::plot::MetiersStat stat, QCustomPlot *plot)
Definition: statscontroller.cpp:339
HarboursStat
Definition: plottypes.h:23
void setMetiersStat(displace::plot::MetiersStat stat)
Definition: statscontroller.cpp:248
void setBenthosStat(displace::plot::BenthosStat stat)
Definition: statscontroller.cpp:254
displace::plot::WindfarmsStat getWindfarmsStat() const
Definition: statscontroller.h:89
displace::plot::NationsStat getNationsStat() const
Definition: statscontroller.h:71
void updateNationStats(DisplaceModel *model, displace::plot::NationsStat mSelectedNationsStat, QCustomPlot *plot)
Definition: statscontroller.cpp:321
void setPopulationPlot(PlotWidget *plot, GraphInteractionController *controller)
Definition: statscontroller.cpp:62
void setCurrentTimeStep(double t)
Definition: statscontroller.cpp:278
Definition: statscontroller.h:64
void setFishfarmsPlot(PlotWidget *plot, GraphInteractionController *controller=nullptr)
Definition: statscontroller.cpp:109
void setWindfarmsStat(displace::plot::WindfarmsStat stat)
Definition: statscontroller.cpp:266
void setNationsStat(displace::plot::NationsStat stat)
Definition: statscontroller.cpp:230
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
Definition: qcustomplot.h:3582
void updatePopulationStats(DisplaceModel *model, displace::plot::PopulationStat popStat, QCustomPlot *plot)
Definition: statscontroller.cpp:313
void setShipsPlot(PlotWidget *plot, GraphInteractionController *controller=nullptr)
Definition: statscontroller.cpp:147
Definition: benthosstatsplot.h:17
Definition: vesselsstatsplot.h:17
Definition: fishfarmsstatsplot.h:18
void setBenthosPlot(PlotWidget *plot, GraphInteractionController *controller)
Definition: statscontroller.cpp:90
void setShipsStat(displace::plot::ShipsStat stat)
Definition: statscontroller.cpp:272
Definition: statscontroller.h:45
void updateWindfarmsStats(DisplaceModel *model, displace::plot::WindfarmsStat stat)
Definition: statscontroller.cpp:357
Definition: populationsstatplot.h:18
void setVesselsStatsPlot(PlotWidget *plot, GraphInteractionController *controller=nullptr)
Definition: statscontroller.cpp:178
Definition: statscontroller.h:64
displace::plot::BenthosStat getBenthosStat() const
Definition: statscontroller.h:83
Definition: displacemodel.h:71
Definition: shipsstatsplot.h:17
MetiersStat
Definition: plottypes.h:26
FishfarmsStat
Definition: plottypes.h:11
Definition: statscontroller.h:64
void setPopulationStat(displace::plot::PopulationStat stat)
Definition: statscontroller.cpp:224
StatType
Definition: statscontroller.h:63
Definition: PlotWidget.h:13
displace::plot::HarboursStat getHarboursStat() const
Definition: statscontroller.h:77
displace::plot::ShipsStat getShipsStat() const
Definition: statscontroller.h:92
void updateShipsStats(DisplaceModel *model, displace::plot::ShipsStat stat)
Definition: statscontroller.cpp:362
displace::plot::MetiersStat getMetiersStat() const
Definition: statscontroller.h:80
NationsStat
Definition: plottypes.h:17
void setWindfarmsPlot(PlotWidget *plot, GraphInteractionController *controller=nullptr)
Definition: statscontroller.cpp:128
Definition: statscontroller.h:64
void plotGraph(DisplaceModel *model, StatType st, int subtype, QCustomPlot *plot=nullptr)
Definition: statscontroller.cpp:292
void setVesselsStat(displace::plot::VesselsStat stat)
Definition: statscontroller.cpp:236
void setMetiersPlot(PlotWidget *plot)
Definition: statscontroller.cpp:82
displace::plot::PopulationStat getPopulationStat() const
Definition: statscontroller.h:68
A line from one point to another.
Definition: qcustomplot.h:6123
Definition: harboursstatplot.h:18
BenthosStat
Definition: plottypes.h:10
Definition: metiersstatsplot.h:17
void setHarboursPlot(PlotWidget *plot)
Definition: statscontroller.cpp:74
PopulationStat
Definition: plottypes.h:7
Definition: statscontroller.h:64
void updateVesselStats(DisplaceModel *model, displace::plot::VesselsStat mSelectedVesselsStat, QCustomPlot *plot)
Definition: statscontroller.cpp:326
displace::plot::FishfarmsStat getFishfarmsStat() const
Definition: statscontroller.h:86
void updateFishfarmsStats(DisplaceModel *model, displace::plot::FishfarmsStat stat)
Definition: statscontroller.cpp:352
Definition: windfarmsstatsplot.h:17
void updateBenthosStats(DisplaceModel *model, displace::plot::BenthosStat stat)
Definition: statscontroller.cpp:347
ShipsStat
Definition: plottypes.h:14
Definition: nationsstatsplot.h:17
void setFishfarmsStat(displace::plot::FishfarmsStat stat)
Definition: statscontroller.cpp:260
void updateHarboursStats(DisplaceModel *model, displace::plot::HarboursStat stat, QCustomPlot *plot)
Definition: statscontroller.cpp:331
void setHarbourStat(displace::plot::HarboursStat stat)
Definition: statscontroller.cpp:242
Definition: graphinteractioncontroller.h:48
Definition: palettemanager.h:62