DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
edgemapobject.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, 2013, 2014 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 #ifndef EDGEMAPOBJECT_H
22 #define EDGEMAPOBJECT_H
23 
24 #include <QObject>
25 
26 #include <mapobjects/mapobject.h>
27 #include <modelobjects/nodedata.h>
29 #include <QMapControl/GeometryLineString.h>
30 #include <QMapControl/Geometry.h>
31 
32 namespace qmapcontrol {
33  class RectWorldCoord;
34 }
35 
37 class NodeDetailsWidget;
38 
39 class EdgeGraphics;
40 
41 class EdgeGraphics : public qmapcontrol::GeometryLineString {
42  static QPen mNormalPen, mSelectedPen;
43 
44  std::shared_ptr<NodeData::Edge> mEdge;
45 public:
46  explicit EdgeGraphics(const std::vector<qmapcontrol::PointWorldCoord>& points, std::shared_ptr<NodeData::Edge> edge);
47 
48  virtual void draw(QPainter& painter, const qmapcontrol::RectWorldCoord& backbuffer_rect_coord, const int& controller_zoom);
49 
50  static const double minZoom, maxZoom, minTextZoom;
51 
52 private:
53  void buildArrow(const qmapcontrol::PointWorldCoord& from, const qmapcontrol::PointWorldCoord &to);
54 };
55 
56 class EdgeMapObject : public QObject, public MapObject
57 {
58  Q_OBJECT
59 
60 public:
61  EdgeMapObject(MapObjectsController *controller, std::shared_ptr<NodeData::Edge> edge);
62 
63  std::shared_ptr<qmapcontrol::Geometry> getGeometryEntity() const {
64  return mGeometry;
65  }
66 
67  bool selected() const { return mGeometry->selected(); }
68 
69  std::shared_ptr<NodeData> node() const { return mEdge->source.lock(); }
70  std::shared_ptr<NodeData> target() const { return mEdge->target.lock(); }
71 protected:
72 
73 private slots:
74 
75 signals:
77 
78 private:
79  MapObjectsController *mController;
80  std::shared_ptr<NodeData::Edge> mEdge;
81 
82  std::shared_ptr<EdgeGraphics> mGeometry;
83  NodeDetailsWidget *mWidget;
84 };
85 
86 #endif // EDGEMAPOBJECT_H
static const double minTextZoom
Definition: edgemapobject.h:50
Definition: myutils.h:206
void edgeSelectionHasChanged(EdgeMapObject *object)
Definition: moc_edgemapobject.cpp:139
EdgeMapObject(MapObjectsController *controller, std::shared_ptr< NodeData::Edge > edge)
Definition: edgemapobject.cpp:41
static const double minZoom
Definition: edgemapobject.h:50
EdgeGraphics(const std::vector< qmapcontrol::PointWorldCoord > &points, std::shared_ptr< NodeData::Edge > edge)
Definition: edgemapobject.cpp:59
Definition: edgemapobject.h:41
virtual void draw(QPainter &painter, const qmapcontrol::RectWorldCoord &backbuffer_rect_coord, const int &controller_zoom)
Definition: edgemapobject.cpp:68
std::shared_ptr< NodeData > node() const
Definition: edgemapobject.h:69
Definition: nodedetailswidget.h:30
Definition: mapobject.h:30
static const double maxZoom
Definition: edgemapobject.h:50
std::shared_ptr< NodeData > target() const
Definition: edgemapobject.h:70
Definition: mapobjectscontroller.h:91
Definition: edgemapobject.h:56
Definition: csvspecspage.h:20
std::shared_ptr< qmapcontrol::Geometry > getGeometryEntity() const
Definition: edgemapobject.h:63
bool selected() const
Definition: edgemapobject.h:67