DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
shortestpathbuilderworker.h
Go to the documentation of this file.
1 #ifndef SHORTESTPATHBUILDERWORKER_H
2 #define SHORTESTPATHBUILDERWORKER_H
3 
4 #include <QObject>
5 #include <QFutureWatcher>
6 #include <shortestpathbuilder.h>
7 
8 #include <backgroundworker.h>
9 #include <displacemodel.h>
10 
11 class WaitDialog;
12 
13 namespace displace {
14 namespace workers {
15 
16 class ShortestPathBuilderWorker : public QObject
17 {
18  Q_OBJECT
19 
20 public:
21  explicit ShortestPathBuilderWorker(QObject *main, WaitDialog *dialog, DisplaceModel *model);
23 
24  void setBinaryFormat() { mTextFormat = false; }
25  void setTextFormat() { mTextFormat = true; }
26  void setRelevantNodes (const QList<std::shared_ptr<NodeData> > &nodes);
27  void setRelevantInterNodes(const QVector<int> &nodes);
28  void run(QObject *obj, const char *slot);
29 
30  enum class AlgorithmType { Dijkstra, Astar };
32  mAlgorithmType = type;
33  }
34 protected:
35  struct arg {
36  std::shared_ptr<NodeData> node;
38  };
39 
40  static void doStep(arg);
41 
42 signals:
43  void finished (bool result);
44 
45 private slots:
46  void completed();
47 
48 private:
49  WaitDialog *mWaitDialog;
50  DisplaceModel *mModel;
51  QList<std::shared_ptr<NodeData>> mRelevantNodes;
52  QVector<int> mRelevantInternNodes;
53  QList<arg> mArgumentList;
54  QFutureWatcher<void> mFutureWatcher;
55  AlgorithmType mAlgorithmType;
56 
57  bool mTextFormat = false;
58 };
59 
60 } // workers
61 } // displace
62 
63 #endif // SHORTESTPATHBUILDERWORKER_H
Definition: decisiontreemanager.h:13
Definition: shortestpathbuilderworker.h:35
vector< Node * > nodes
Definition: main.cpp:270
std::shared_ptr< NodeData > node
Definition: shortestpathbuilderworker.h:36
void setBinaryFormat()
Definition: shortestpathbuilderworker.h:24
void setTextFormat()
Definition: shortestpathbuilderworker.h:25
int main(int argc, char *argv[])
Definition: dteditor.cpp:27
AlgorithmType
Definition: shortestpathbuilderworker.h:30
static void doStep(arg)
Definition: shortestpathbuilderworker.cpp:50
void setRelevantInterNodes(const QVector< int > &nodes)
Definition: shortestpathbuilderworker.cpp:30
ShortestPathBuilderWorker(QObject *main, WaitDialog *dialog, DisplaceModel *model)
Definition: shortestpathbuilderworker.cpp:11
Definition: displacemodel.h:71
ShortestPathBuilderWorker * me
Definition: shortestpathbuilderworker.h:37
Definition: waitdialog.h:56
void run(QObject *obj, const char *slot)
Definition: shortestpathbuilderworker.cpp:35
void finished(bool result)
Definition: moc_shortestpathbuilderworker.cpp:133
virtual ~ShortestPathBuilderWorker()
Definition: shortestpathbuilderworker.h:22
void setRelevantNodes(const QList< std::shared_ptr< NodeData > > &nodes)
Definition: shortestpathbuilderworker.cpp:19
void setAlgorithmType(AlgorithmType type)
Definition: shortestpathbuilderworker.h:31
Definition: shortestpathbuilderworker.h:16