Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
frechet::view::CurveView Class Reference

Detailed Description

displays input curves P and Q.

Curves can be drawn separated for better readability.

If the algorithm for simple polygons is appplied, c-diagonals and t-diagonals are displayed.

Polygon edges and diagonals are mouse sensitive. When the mouse hovers over and edge (or diagonal) the corresponding edges of the feasible path are highlighted.

Author
Peter Schäfer

Definition at line 22 of file curveview.h.

#include <curveview.h>

Inherits frechet::view::BaseView.

Public Slots

void setSeparateCurves (bool sep)
 update the display to show curves separately, or not More...
 
void onAlgorithmChanged (int alg)
 called when the user changes the current algorithm. Update the curve display accordingly (e.g. show, or hide diagonals). More...
 
void onHiliteSegment (int loc, int a, int b)
 called when a line segment should be highlighted More...
 
- Public Slots inherited from frechet::view::BaseView
void zoomIn (int level=-1)
 zoom in; connected to the zomm controls More...
 
void zoomOut (int level=-1)
 connected to the zomm controls More...
 
void flipVertical (bool flip)
 flip graphics scene vertically More...
 
void mouseMoveEvent (QMouseEvent *event)
 handles a mouse move event and detects mouse sensitve polygon segments More...
 
QPoint mapSceneToGlobal (QPointF p) const
 map scene coordinates to window coordinate More...
 

Signals

void hiliteSegment (int loc, int a, int b)
 raised when a mouse sensitive line segment is highlighted. Parameters identify the location of the line segment. More...
 

Public Member Functions

 CurveView (QWidget *parent=0)
 default constructor with parent More...
 
void populateScene (const Curve &P, const Curve &Q, frechet::poly::Algorithm::ptr alg)
 set up the graphics scene with polygonal curves More...
 
virtual void saveSettings (QSettings &settings, QString group)
 store settings to application preferences More...
 
virtual void restoreSettings (QSettings &settings, QString group)
 load settings from application preferences More...
 
bool separateCurves () const
 
virtual void segmentSelected (GraphicsHoverLineItem *item) override
 called when the mouse hovers over a sensitive line segment. Updates the corresponding line segments. More...
 
- Public Member Functions inherited from frechet::view::BaseView
 BaseView (QWidget *parent=0, QString title="", bool showRotate=true)
 constructore with parent and title More...
 
QGraphicsView * view () const
 

Private Member Functions

void doHiliteSegment (GraphicsHoverLineItem::Location loc, int a, int b)
 highlight a line segment More...
 
QGraphicsItemGroup * addPolygonToScene (const Curve &poly, QPen pen, GraphicsHoverLineItem::Location hover)
 add a polygon curve to the graphics scene More...
 
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 More...
 
QGraphicsItemGroup * addSegmentsToScene (QGraphicsItemGroup *group, const frechet::poly::Segments &d, bool with_edges, QPen pen, const Curve &P, GraphicsHoverLineItem::Location hover)
 add a number of line segments to the graphics scene More...
 
QGraphicsLineItem * createLineItem (QLineF line, QPen pen, frechet::poly::Segment seg, QGraphicsItemGroup *group, GraphicsHoverLineItem::Location hover)
 create a line segment graphics item More...
 

Private Attributes

bool _separate
 draw curves separately? More...
 
QGraphicsItemGroup * polygon_a
 graphics items for (boundary of) curve P More...
 
QGraphicsItemGroup * polygon_b
 graphics items for (boundary of) curve Q More...
 
QGraphicsItemGroup * diagonals_a
 graphics items for diagonals of curve P More...
 
QGraphicsItemGroup * diagonals_b
 
QRectF polygon_bounds
 boundary rectangle for both curves More...
 
QGraphicsPathItem * select_a
 highlited items for curve P More...
 
QGraphicsPathItem * select_b
 highlited items for curve Q More...
 

Static Private Attributes

static const QPen PEN_A
 pen for drawing the curve P More...
 
static const QPen PEN_B
 pen for drawing the curve Q More...
 
static const QPen PEN_C_DIAGS
 pen for drawing the c-diagonals in P More...
 
static const QPen PEN_T_DIAGS
 pen for drawing the t-diagonals in P More...
 
static const QPen PEN_PASSIVE_DIAGS
 
static const double SEPARATOR = 0.06
 distance when curves are displayed separately More...
 

Friends

class GraphicsHoverLineItem
 

Additional Inherited Members

- Protected Slots inherited from frechet::view::BaseView
void resetView ()
 reset zoom to default More...
 
void setResetButtonEnabled ()
 enabled reset button More...
 
void setupMatrix ()
 set up transformation matrix to account for zoom,rotate,scroll More...
 
void print ()
 print the contents of the graphics scene More...
 
void saveAs ()
 save the contents of the graphics scene to disk (as PDF, or SVG) More...
 
void rotateLeft (double angle=10)
 rotate the scene to the left More...
 
void rotateRight (double angle=10)
 rotate the scene to the right More...
 
int rotation () const
 
void setRotation (double angle)
 update rotation angle More...
 
- Protected Member Functions inherited from frechet::view::BaseView
void resizeEvent (QResizeEvent *) override
 handles window resizes; adjusts controls to new window size More...
 
void saveAsPdf (QString file)
 save content of scene to a PDF file More...
 
void saveAsSvg (QString file)
 save content of scene to an SVG file More...
 
virtual void dropUnusedItems ()
 clean up graphics scene items after free-space is modified implemented by FreeSpaceView. More...
 
virtual void render (QPainter *painter, QRectF target=QRectF())
 render the scene into a QPainter used for printing and saving to disk More...
 
QMatrix baseMatrix ()
 
- Static Protected Member Functions inherited from frechet::view::BaseView
static void setPenWidth (QGraphicsItem *item, double width)
 update the pen width of a graphics item More...
 
static void addLine (QPainterPath &ppath, const QLineF &line)
 add a line segment to a QPainterPath More...
 
static void addPolygon (QPainterPath &ppath, const QPolygonF &poly)
 add a polygon curve segment to a QPainterPath More...
 
static void addPoint (QPainterPath &ppath, const QPointF &point, double diameter=1.0)
 add a dot to a QPainterPath More...
 
- Protected Attributes inherited from frechet::view::BaseView
QGraphicsView * graphicsView
 the embedded QGraphicsView More...
 
QGraphicsScene * scene
 scene that is displayed by graphicsView More...
 
bool isFlipped
 true if the scene should be flipped vertically More...
 
int zoomStepMouse
 zoom step for mouse wheel More...
 
int zoomStepDefault
 default zoom step More...
 
QToolButton * resetButton
 the reset button More...
 
QSlider * zoomSlider
 the slider control for zoom More...
 
QSlider * rotateSlider
 the slider control for rotate More...
 
GraphicsHoverLineItemselected_item
 the currently selected mouse sensitve polyon segment (or nullptr) More...
 
- Static Protected Attributes inherited from frechet::view::BaseView
static const QPen PEN_SELECT
 pen for drawing selected polygon segment More...
 
static const int ROTATE_DEFAULT_VALUE = 0
 what this? More...
 
static const QStringList OUTPUT_FILTERS
 file name filters for save dialog More...
 

Constructor & Destructor Documentation

◆ CurveView()

CurveView::CurveView ( QWidget *  parent = 0)

default constructor with parent

Parameters
parentparent widget (optional)

Definition at line 21 of file curveview.cpp.

Member Function Documentation

◆ addPolygonToScene()

QGraphicsItemGroup * CurveView::addPolygonToScene ( const Curve poly,
QPen  pen,
GraphicsHoverLineItem::Location  hover 
)
private

add a polygon curve to the graphics scene

Parameters
polythe polygon curve
penpen for drawing the curve
hoverhover location
Returns
a group of graphics items

Definition at line 106 of file curveview.cpp.

◆ addSegmentsToScene() [1/2]

QGraphicsItemGroup* frechet::view::CurveView::addSegmentsToScene ( QGraphicsItemGroup *  group,
frechet::poly::Triangulation::Edge_range  d,
const frechet::poly::Segments exclude,
bool  with_edges,
QPen  pen,
GraphicsHoverLineItem::Location  hover 
)
private

add a number of line segments to the graphics scene

Parameters
groupgroup to add the items to
da number of polygon edges
excludeset of segments to exclude
with_edgesinclude outer edges?
penpen for drawing
hoverhover location
Returns
a group of graphics items

◆ addSegmentsToScene() [2/2]

QGraphicsItemGroup* frechet::view::CurveView::addSegmentsToScene ( QGraphicsItemGroup *  group,
const frechet::poly::Segments d,
bool  with_edges,
QPen  pen,
const Curve P,
GraphicsHoverLineItem::Location  hover 
)
private

add a number of line segments to the graphics scene

Parameters
groupgroup to add the items to
da number of polygon edges
with_edgesinclude outer edges?
penpen for drawing
Ppolygonal curve
hoverhover location
Returns
a group of graphics items

◆ createLineItem()

QGraphicsLineItem * CurveView::createLineItem ( QLineF  line,
QPen  pen,
frechet::poly::Segment  seg,
QGraphicsItemGroup *  group,
GraphicsHoverLineItem::Location  hover 
)
private

create a line segment graphics item

Parameters
linethe line segment
penpen for drawing
segthe associated polygon segment
groupp group to add the items to
hoverhover location
Returns
a graphics item

Definition at line 167 of file curveview.cpp.

◆ doHiliteSegment()

void CurveView::doHiliteSegment ( GraphicsHoverLineItem::Location  loc,
int  a,
int  b 
)
private

highlight a line segment

Parameters
loclocation on screen
aidentifier
bidentifier
See also
GraphicsHoverLineItem

Definition at line 273 of file curveview.cpp.

◆ hiliteSegment

void frechet::view::CurveView::hiliteSegment ( int  loc,
int  a,
int  b 
)
signal

raised when a mouse sensitive line segment is highlighted. Parameters identify the location of the line segment.

Parameters
loclocation on screen
aidentifier
bidentifier
See also
GraphicsHoverLineItem

◆ onAlgorithmChanged

void CurveView::onAlgorithmChanged ( int  alg)
slot

called when the user changes the current algorithm. Update the curve display accordingly (e.g. show, or hide diagonals).

Parameters
algcurrent algorithm
See also
FrechetViewAlgorithm::Algorithm

Definition at line 355 of file curveview.cpp.

◆ onHiliteSegment

void CurveView::onHiliteSegment ( int  loc,
int  a,
int  b 
)
slot

called when a line segment should be highlighted

Parameters
loclocation on screen
aidentifier
bidentifier
See also
GraphicsHoverLineItem

Definition at line 268 of file curveview.cpp.

◆ populateScene()

void CurveView::populateScene ( const Curve P,
const Curve Q,
frechet::poly::Algorithm::ptr  alg 
)

set up the graphics scene with polygonal curves

Parameters
Pthe first input curve
Qthe second input curve
algthe algorithm for simple polygons

Definition at line 32 of file curveview.cpp.

◆ restoreSettings()

void CurveView::restoreSettings ( QSettings &  settings,
QString  group 
)
virtual

load settings from application preferences

Parameters
settingsapplication preferences
groupsection where to store settings

Reimplemented from frechet::view::BaseView.

Definition at line 189 of file curveview.cpp.

◆ saveSettings()

void CurveView::saveSettings ( QSettings &  settings,
QString  group 
)
virtual

store settings to application preferences

Parameters
settingsapplication preferences
groupsection where to store settings

Reimplemented from frechet::view::BaseView.

Definition at line 180 of file curveview.cpp.

◆ segmentSelected()

void CurveView::segmentSelected ( GraphicsHoverLineItem item)
overridevirtual

called when the mouse hovers over a sensitive line segment. Updates the corresponding line segments.

Parameters
itemthe line segment

Reimplemented from frechet::view::BaseView.

Definition at line 252 of file curveview.cpp.

◆ separateCurves()

bool frechet::view::CurveView::separateCurves ( ) const
inline
Returns
true if curves are displayed beneath each other

Definition at line 56 of file curveview.h.

◆ setSeparateCurves

void CurveView::setSeparateCurves ( bool  sep)
slot

update the display to show curves separately, or not

Parameters
septrue if the curves should be displayed separately

Definition at line 200 of file curveview.cpp.

Friends And Related Function Documentation

◆ GraphicsHoverLineItem

friend class GraphicsHoverLineItem
friend

Definition at line 178 of file curveview.h.

Member Data Documentation

◆ _separate

bool frechet::view::CurveView::_separate
private

draw curves separately?

Definition at line 115 of file curveview.h.

◆ diagonals_a

QGraphicsItemGroup* frechet::view::CurveView::diagonals_a
private

graphics items for diagonals of curve P

Definition at line 119 of file curveview.h.

◆ diagonals_b

QGraphicsItemGroup* frechet::view::CurveView::diagonals_b
private

graphics items for diagonals of curve Q

Definition at line 120 of file curveview.h.

◆ PEN_A

const QPen CurveView::PEN_A
staticprivate

pen for drawing the curve P

Definition at line 107 of file curveview.h.

◆ PEN_B

const QPen CurveView::PEN_B
staticprivate

pen for drawing the curve Q

Definition at line 108 of file curveview.h.

◆ PEN_C_DIAGS

const QPen CurveView::PEN_C_DIAGS
staticprivate

pen for drawing the c-diagonals in P

Definition at line 109 of file curveview.h.

◆ PEN_PASSIVE_DIAGS

const QPen CurveView::PEN_PASSIVE_DIAGS
staticprivate

pen for drawing the diagonals in Q

Definition at line 111 of file curveview.h.

◆ PEN_T_DIAGS

const QPen CurveView::PEN_T_DIAGS
staticprivate

pen for drawing the t-diagonals in P

Definition at line 110 of file curveview.h.

◆ polygon_a

QGraphicsItemGroup* frechet::view::CurveView::polygon_a
private

graphics items for (boundary of) curve P

Definition at line 117 of file curveview.h.

◆ polygon_b

QGraphicsItemGroup* frechet::view::CurveView::polygon_b
private

graphics items for (boundary of) curve Q

Definition at line 118 of file curveview.h.

◆ polygon_bounds

QRectF frechet::view::CurveView::polygon_bounds
private

boundary rectangle for both curves

Definition at line 122 of file curveview.h.

◆ select_a

QGraphicsPathItem* frechet::view::CurveView::select_a
private

highlited items for curve P

Definition at line 124 of file curveview.h.

◆ select_b

QGraphicsPathItem* frechet::view::CurveView::select_b
private

highlited items for curve Q

Definition at line 125 of file curveview.h.

◆ SEPARATOR

const double CurveView::SEPARATOR = 0.06
staticprivate

distance when curves are displayed separately

Definition at line 113 of file curveview.h.


The documentation for this class was generated from the following files: