Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
curveview.h
Go to the documentation of this file.
1 #ifndef CURVEVIEW_H
2 #define CURVEVIEW_H
3 
4 #include <baseview.h>
5 #include <QAbstractGraphicsShapeItem>
6 #include <poly/algorithm.h>
7 
8 namespace frechet { namespace view {
9 
22 class CurveView : public BaseView
23 {
24  Q_OBJECT
25 public:
30  CurveView(QWidget *parent = 0);
31 
38  void populateScene(const Curve& P, const Curve& Q, frechet::poly::Algorithm::ptr alg);
39 
45  virtual void saveSettings(QSettings& settings, QString group);
51  virtual void restoreSettings(QSettings& settings, QString group);
52 
56  bool separateCurves() const { return _separate; }
62  virtual void segmentSelected(GraphicsHoverLineItem *item) override;
63 
64 signals:
73  void hiliteSegment(int loc, int a, int b);
74 
75 public slots:
80  void setSeparateCurves(bool sep);
87  void onAlgorithmChanged(int alg);
95  void onHiliteSegment(int loc, int a, int b);
96 
97 private:
105  void doHiliteSegment(GraphicsHoverLineItem::Location loc, int a, int b);
106 
107  static const QPen PEN_A;
108  static const QPen PEN_B;
109  static const QPen PEN_C_DIAGS;
110  static const QPen PEN_T_DIAGS;
111  static const QPen PEN_PASSIVE_DIAGS;
112  static const double SEPARATOR;
115  bool _separate;
116 
117  QGraphicsItemGroup *polygon_a;
118  QGraphicsItemGroup *polygon_b;
119  QGraphicsItemGroup *diagonals_a;
120  QGraphicsItemGroup *diagonals_b;
121  QRectF polygon_bounds;
123 
124  QGraphicsPathItem *select_a;
125  QGraphicsPathItem *select_b;
126 
134  QGraphicsItemGroup* addPolygonToScene(const Curve& poly, QPen pen, GraphicsHoverLineItem::Location hover);
145  QGraphicsItemGroup* addSegmentsToScene(QGraphicsItemGroup* group,
147  const frechet::poly::Segments& exclude,
148  bool with_edges,
149  QPen pen, GraphicsHoverLineItem::Location hover);
160  QGraphicsItemGroup* addSegmentsToScene(QGraphicsItemGroup* group,
161  const frechet::poly::Segments& d,
162  bool with_edges,
163  QPen pen,
164  const Curve& P, GraphicsHoverLineItem::Location hover);
174  QGraphicsLineItem* createLineItem(QLineF line, QPen pen,
176  QGraphicsItemGroup* group, GraphicsHoverLineItem::Location hover);
177 
178  friend class GraphicsHoverLineItem;
179 };
180 
181 } } // namespace frechet::view
182 #endif // CURVEVIEW_H
base class for view widgets.
Definition: baseview.h:79
Represents a polygon line segment from node i to j.
Definition: types.h:39
QGraphicsItemGroup * addPolygonToScene(const Curve &poly, QPen pen, GraphicsHoverLineItem::Location hover)
add a polygon curve to the graphics scene
Definition: curveview.cpp:106
void onAlgorithmChanged(int alg)
called when the user changes the current algorithm. Update the curve display accordingly (e....
Definition: curveview.cpp:355
QGraphicsItemGroup * polygon_b
graphics items for (boundary of) curve Q
Definition: curveview.h:118
bool separateCurves() const
Definition: curveview.h:56
QGraphicsLineItem * createLineItem(QLineF line, QPen pen, frechet::poly::Segment seg, QGraphicsItemGroup *group, GraphicsHoverLineItem::Location hover)
create a line segment graphics item
Definition: curveview.cpp:167
global definitions for all algorithms.
static const QPen PEN_PASSIVE_DIAGS
Definition: curveview.h:111
std::set< Segment > Segments
a set of Segment objects
Definition: types.h:115
void hiliteSegment(int loc, int a, int b)
raised when a mouse sensitive line segment is highlighted. Parameters identify the location of the li...
void populateScene(const Curve &P, const Curve &Q, frechet::poly::Algorithm::ptr alg)
set up the graphics scene with polygonal curves
Definition: curveview.cpp:32
void setSeparateCurves(bool sep)
update the display to show curves separately, or not
Definition: curveview.cpp:200
boost::shared_ptr< Algorithm > ptr
(smart) pointer to an Algorithm object
Definition: algorithm.h:236
displays input curves P and Q.
Definition: curveview.h:22
virtual void restoreSettings(QSettings &settings, QString group)
load settings from application preferences
Definition: curveview.cpp:189
static const QPen PEN_T_DIAGS
pen for drawing the t-diagonals in P
Definition: curveview.h:110
QGraphicsItemGroup * diagonals_b
Definition: curveview.h:120
std::pair< Edge_iterator, Edge_iterator > Edge_range
a range of edges
static const QPen PEN_A
pen for drawing the curve P
Definition: curveview.h:107
CurveView(QWidget *parent=0)
default constructor with parent
Definition: curveview.cpp:21
a QGraphicsLitem that can handle mouse hover events. It is used to highlight mouse sensitve polygon s...
Definition: baseview.h:239
static const QPen PEN_C_DIAGS
pen for drawing the c-diagonals in P
Definition: curveview.h:109
virtual void saveSettings(QSettings &settings, QString group)
store settings to application preferences
Definition: curveview.cpp:180
static const QPen PEN_B
pen for drawing the curve Q
Definition: curveview.h:108
QGraphicsItemGroup * addSegmentsToScene(QGraphicsItemGroup *group, frechet::poly::Triangulation::Edge_range d, const frechet::poly::Segments &exclude, bool with_edges, QPen pen, GraphicsHoverLineItem::Location hover)
add a number of line segments to the graphics scene
static const double SEPARATOR
distance when curves are displayed separately
Definition: curveview.h:113
QPolygonF Curve
a polygonal curve in the plane; with double floating point precision. This type is heavily used throu...
Definition: types.h:20
QRectF polygon_bounds
boundary rectangle for both curves
Definition: curveview.h:122
void onHiliteSegment(int loc, int a, int b)
called when a line segment should be highlighted
Definition: curveview.cpp:268
QGraphicsItemGroup * diagonals_a
graphics items for diagonals of curve P
Definition: curveview.h:119
QGraphicsItemGroup * polygon_a
graphics items for (boundary of) curve P
Definition: curveview.h:117
void doHiliteSegment(GraphicsHoverLineItem::Location loc, int a, int b)
highlight a line segment
Definition: curveview.cpp:273
bool _separate
draw curves separately?
Definition: curveview.h:115
QGraphicsPathItem * select_a
highlited items for curve P
Definition: curveview.h:124
virtual void segmentSelected(GraphicsHoverLineItem *item) override
called when the mouse hovers over a sensitive line segment. Updates the corresponding line segments.
Definition: curveview.cpp:252
Location
location of the polygon segment
Definition: baseview.h:243
QGraphicsPathItem * select_b
highlited items for curve Q
Definition: curveview.h:125