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

Detailed Description

display the free-space diagram.

It is made up of a line grid and an array of CellView objects. Cell contents adjusts automatically at changes of epsilon. When epsilon changes, FreeSpaceView executes the decision variant of the curve algorithm.

When the k-Frechet algorithm is selected, connected components are color-coded. Component boundaries can be shown as intervals below the free-space diagram.

Optionally, a feasible path is displayed as one (or two) polygonal chains. Line segments of the feasible path are mouse hover sensitive.

Optionally, reachable intervals are displayed at the cell edges (along the grid lines).

Author
Peter Schäfer

Definition at line 199 of file freespaceview.h.

#include <freespaceview.h>

Inherits frechet::view::BaseView.

Public Slots

void calculateFreeSpace (double epsilon)
 update free-space diagram when epsilon changes. If the curve algorithm is selected, compute a feasible path, too. All other algorithms must be triggered by the user. More...
 
void showBounds (bool show)
 update display of bounding rects More...
 
void showGreedyResult ()
 show the result of the k-Frechet greedy algorithms. Highlights all components that are part of the solution, other components are grayed. More...
 
void showOptimalResult ()
 show the optimal result of the k-Frechet (brute-force) algorithms. Highlights all components that are part of the solution, other components are grayed. More...
 
void hideResult ()
 hide results of the k-Frechet algorithms. Remove gray-out, display all components in their original color. More...
 
void showPath (bool show)
 show or hide feasible path More...
 
void onHiliteSegment (int loc, int a, int b)
 highlight a segment of the feasible path More...
 
void onAlgorithmChanged (int alg)
 updatee free-space diagram when a new algorithm is selected. For example, for the k-Frechet algorithm, components are color-coded. More...
 
void hilitePoint (QPointF p)
 hilite on point inf the diagram (used for animation only) 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...
 
- 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...
 
virtual void saveSettings (QSettings &settings, QString group)
 store view settings to application prefs More...
 
virtual void restoreSettings (QSettings &settings, QString group)
 load view settings to application prefs 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 curveFinished (bool yes)
 raised when after decision variant of the curve algorithm More...
 
void hiliteSegment (int loc, int a, int b)
 raised when the mouse moves over a highlighted segment This signal triggers the display of associated line items. More...
 

Public Member Functions

 FreeSpaceView (QWidget *parent=0)
 default constructor More...
 
virtual ~FreeSpaceView ()
 destructor; releases all items More...
 
void populateScene ()
 create the grid lines and an array of CellView objects More...
 
bool showBounds () const
 
virtual void dropUnusedItems () override
 release graphics items that are currently not drawn implements empty method from super-class More...
 
virtual void segmentSelected (GraphicsHoverLineItem *item) override
 called when the mouse hovers over a sensitve line item 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
 

Public Attributes

QPen GRID_PEN [4]
 
QPen AREA_PEN
 pen for content area More...
 
QPen BOUNDS_PEN
 pen for bounding rectangles More...
 
QPen PATH_PEN
 pen for feasible path More...
 

Static Public Attributes

static const QBrush AREA_BRUSH1
 brush (fill color) for content area More...
 
static const QBrush AREA_BRUSH2
 brush (fill color) for content area More...
 
static const double TF_MAX_ARG = 1e6
 max. value for affine transforms More...
 
static const QColor LIGHT_GRAY
 used for disabled components (k-Frechet) More...
 
static const QColor AREA_COLOR
 color for content area (except k-Frechet) More...
 

Private Member Functions

CellViewgetCellView (int i, int j)
 get a free-space cell view More...
 
void updateView (double eps)
 update free-space view in response to a change of epsilon More...
 
void updateBounds ()
 update bounding rectangles More...
 
void updateIntervals ()
 update component intervals (k-Frechet only) More...
 
void showResult (const data::BitSet *resultSet)
 show the result of a k-Frechet algorithm More...
 
void createBoundsRect (int i, int j, QLineF result[4])
 create a boundary rectangle for a cell More...
 
void createReachabilityRect (int i, int j, QLineF result[4])
 create a set of line segments for reachability intervals More...
 
QLineF boundsLine (QPointF a, QPointF b, int i, int j)
 calculates one boundary line More...
 
QTransform createEllipseTransform (int i, int j)
 compute the transformation for drawing an ellipse More...
 
void addGridLine (QLineF line, LineStyle style)
 add a grid line to the graphics scene More...
 
void doHiliteSegment (GraphicsHoverLineItem::Location loc, int a, int b)
 highlight a line segment More...
 

Static Private Member Functions

static bool validTransform (const QTransform &tf)
 validity test for a transformation. If transform parameters become excessively large, the ellipse is replaced by an approximating polygon. More...
 
static bool validTransformArg (double x)
 validity test for a transformation More...
 

Private Attributes

bool path_ok
 true, if there is a feasible path More...
 
bool _showBounds
 true, if bounding rectangle are shown More...
 
Palette componentPalette
 
CellView::MatrixPtr cells
 free space areas for all cells (i,j) More...
 
IntervalViewintervalView [2]
 k-Frechet: show component intervals below and to the left More...
 
QGraphicsItemGroup * pathView
 the feasible path More...
 
QGraphicsPathItem * select
 highlighted line segment (or nullptr) More...
 

Friends

class CellView
 

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 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

◆ FreeSpaceView()

FreeSpaceView::FreeSpaceView ( QWidget *  parent = 0)

default constructor

Parameters
parentparen widget (optional)

Definition at line 31 of file freespaceview.cpp.

◆ ~FreeSpaceView()

FreeSpaceView::~FreeSpaceView ( )
virtual

destructor; releases all items

Definition at line 51 of file freespaceview.cpp.

Member Function Documentation

◆ addGridLine()

void FreeSpaceView::addGridLine ( QLineF  line,
LineStyle  style 
)
private

add a grid line to the graphics scene

Parameters
linegrid line
styledrawing style

Definition at line 508 of file freespaceview.cpp.

◆ boundsLine()

QLineF FreeSpaceView::boundsLine ( QPointF  a,
QPointF  b,
int  i,
int  j 
)
private

calculates one boundary line

Parameters
astart of line in free-space coordinates
bend of line in free-space coordinates
igrid column
jgrid row
Returns
a line to draw in the free-space diagram

Definition at line 1029 of file freespaceview.cpp.

◆ calculateFreeSpace

void FreeSpaceView::calculateFreeSpace ( double  epsilon)
slot

update free-space diagram when epsilon changes. If the curve algorithm is selected, compute a feasible path, too. All other algorithms must be triggered by the user.

Parameters
epsilonnew value of epsilon

Definition at line 161 of file freespaceview.cpp.

◆ createBoundsRect()

void FreeSpaceView::createBoundsRect ( int  i,
int  j,
QLineF  result[4] 
)
private

create a boundary rectangle for a cell

Parameters
igrid column
jgrid row
resultholds the boundary lines on return

Definition at line 956 of file freespaceview.cpp.

◆ createEllipseTransform()

QTransform FreeSpaceView::createEllipseTransform ( int  i,
int  j 
)
private

compute the transformation for drawing an ellipse

Parameters
igrid column
jgrid row
Returns
transformation

Definition at line 463 of file freespaceview.cpp.

◆ createReachabilityRect()

void FreeSpaceView::createReachabilityRect ( int  i,
int  j,
QLineF  result[4] 
)
private

create a set of line segments for reachability intervals

Parameters
igrid column
jgrid row
resultholds the reachability intervals on return

Definition at line 982 of file freespaceview.cpp.

◆ curveFinished

void frechet::view::FreeSpaceView::curveFinished ( bool  yes)
signal

raised when after decision variant of the curve algorithm

Parameters
yesif there is a feasible path for the curve algorithm

◆ doHiliteSegment()

void FreeSpaceView::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 561 of file freespaceview.cpp.

◆ dropUnusedItems()

void FreeSpaceView::dropUnusedItems ( )
overridevirtual

release graphics items that are currently not drawn implements empty method from super-class

Reimplemented from frechet::view::BaseView.

Definition at line 134 of file freespaceview.cpp.

◆ getCellView()

CellView * FreeSpaceView::getCellView ( int  i,
int  j 
)
private

get a free-space cell view

Parameters
igrid column
jgrid row
Returns
cell view

Definition at line 149 of file freespaceview.cpp.

◆ hideResult

void FreeSpaceView::hideResult ( )
slot

hide results of the k-Frechet algorithms. Remove gray-out, display all components in their original color.

Definition at line 536 of file freespaceview.cpp.

◆ hilitePoint

void FreeSpaceView::hilitePoint ( QPointF  p)
slot

hilite on point inf the diagram (used for animation only)

Parameters
pa point

Definition at line 629 of file freespaceview.cpp.

◆ hiliteSegment

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

raised when the mouse moves over a highlighted segment This signal triggers the display of associated line items.

Parameters
loclocation on screen
aidentifier
bidentifier
See also
GraphicsHoverLineItem

◆ onAlgorithmChanged

void FreeSpaceView::onAlgorithmChanged ( int  alg)
slot

updatee free-space diagram when a new algorithm is selected. For example, for the k-Frechet algorithm, components are color-coded.

Parameters
algnext algorithm
See also
FrechetViewApplication::Algorithm

Definition at line 1038 of file freespaceview.cpp.

◆ onHiliteSegment

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

highlight a segment of the feasible path

Parameters
loclocation on screen
aidentifier
bidentifier
See also
GraphicsHoverLineItem

Definition at line 556 of file freespaceview.cpp.

◆ populateScene()

void FreeSpaceView::populateScene ( )

create the grid lines and an array of CellView objects

Definition at line 59 of file freespaceview.cpp.

◆ restoreSettings

void FreeSpaceView::restoreSettings ( QSettings &  settings,
QString  group 
)
virtualslot

load settings from application preferences

Parameters
settingsapplication preferences
groupsection where to store settings

Definition at line 648 of file freespaceview.cpp.

◆ saveSettings

void FreeSpaceView::saveSettings ( QSettings &  settings,
QString  group 
)
virtualslot

store settings to application preferences

Parameters
settingsapplication preferences
groupsection where to store settings

Definition at line 639 of file freespaceview.cpp.

◆ segmentSelected()

void FreeSpaceView::segmentSelected ( GraphicsHoverLineItem item)
overridevirtual

called when the mouse hovers over a sensitve line item

Reimplemented from frechet::view::BaseView.

Definition at line 541 of file freespaceview.cpp.

◆ showBounds() [1/2]

bool frechet::view::FreeSpaceView::showBounds ( ) const
inline
Returns
true if bounding rectangles are displayed

Definition at line 227 of file freespaceview.h.

◆ showBounds [2/2]

void frechet::view::FreeSpaceView::showBounds ( bool  show)
slot

update display of bounding rects

Parameters
showwhether to show bounding rects

◆ showGreedyResult

void FreeSpaceView::showGreedyResult ( )
slot

show the result of the k-Frechet greedy algorithms. Highlights all components that are part of the solution, other components are grayed.

Definition at line 524 of file freespaceview.cpp.

◆ showOptimalResult

void FreeSpaceView::showOptimalResult ( )
slot

show the optimal result of the k-Frechet (brute-force) algorithms. Highlights all components that are part of the solution, other components are grayed.

Definition at line 530 of file freespaceview.cpp.

◆ showPath

void FreeSpaceView::showPath ( bool  show)
slot

show or hide feasible path

Parameters
showwhether to show the feasible path

Definition at line 295 of file freespaceview.cpp.

◆ showResult()

void FreeSpaceView::showResult ( const data::BitSet resultSet)
private

show the result of a k-Frechet algorithm

Parameters
resultSeta set of highlighted components

Definition at line 429 of file freespaceview.cpp.

◆ updateBounds()

void FreeSpaceView::updateBounds ( )
private

update bounding rectangles

Definition at line 345 of file freespaceview.cpp.

◆ updateIntervals()

void FreeSpaceView::updateIntervals ( )
private

update component intervals (k-Frechet only)

Definition at line 390 of file freespaceview.cpp.

◆ updateView()

void FreeSpaceView::updateView ( double  eps)
private

update free-space view in response to a change of epsilon

Parameters
epsnew value of epsilon

Definition at line 228 of file freespaceview.cpp.

◆ validTransform()

bool FreeSpaceView::validTransform ( const QTransform &  tf)
staticprivate

validity test for a transformation. If transform parameters become excessively large, the ellipse is replaced by an approximating polygon.

Parameters
tfan affine transformation
Returns
true if the transform is valid

Definition at line 488 of file freespaceview.cpp.

◆ validTransformArg()

bool FreeSpaceView::validTransformArg ( double  x)
staticprivate

validity test for a transformation

Parameters
xentry in a transformation matrix
Returns
true, if x <= TF_MAX_ARG

Definition at line 501 of file freespaceview.cpp.

Friends And Related Function Documentation

◆ CellView

friend class CellView
friend

Definition at line 320 of file freespaceview.h.

Member Data Documentation

◆ _showBounds

bool frechet::view::FreeSpaceView::_showBounds
private

true, if bounding rectangle are shown

Definition at line 324 of file freespaceview.h.

◆ AREA_BRUSH1

const QBrush FreeSpaceView::AREA_BRUSH1
static

brush (fill color) for content area

Definition at line 209 of file freespaceview.h.

◆ AREA_BRUSH2

const QBrush FreeSpaceView::AREA_BRUSH2
static

brush (fill color) for content area

Definition at line 210 of file freespaceview.h.

◆ AREA_COLOR

const QColor FreeSpaceView::AREA_COLOR
static

color for content area (except k-Frechet)

Definition at line 213 of file freespaceview.h.

◆ AREA_PEN

QPen frechet::view::FreeSpaceView::AREA_PEN

pen for content area

Definition at line 206 of file freespaceview.h.

◆ BOUNDS_PEN

QPen frechet::view::FreeSpaceView::BOUNDS_PEN

pen for bounding rectangles

Definition at line 207 of file freespaceview.h.

◆ cells

CellView::MatrixPtr frechet::view::FreeSpaceView::cells
private

free space areas for all cells (i,j)

Definition at line 330 of file freespaceview.h.

◆ componentPalette

Palette frechet::view::FreeSpaceView::componentPalette
private

a palette of colors, used to color-code components for the k-Frechet algorithm

Definition at line 327 of file freespaceview.h.

◆ GRID_PEN

QPen frechet::view::FreeSpaceView::GRID_PEN[4]

pens for drawing grid lines with different styles

See also
LineStyle

Definition at line 205 of file freespaceview.h.

◆ intervalView

IntervalView* frechet::view::FreeSpaceView::intervalView[2]
private

k-Frechet: show component intervals below and to the left

Definition at line 333 of file freespaceview.h.

◆ LIGHT_GRAY

const QColor FreeSpaceView::LIGHT_GRAY
static

used for disabled components (k-Frechet)

Definition at line 212 of file freespaceview.h.

◆ path_ok

bool frechet::view::FreeSpaceView::path_ok
private

true, if there is a feasible path

Definition at line 322 of file freespaceview.h.

◆ PATH_PEN

QPen frechet::view::FreeSpaceView::PATH_PEN

pen for feasible path

Definition at line 208 of file freespaceview.h.

◆ pathView

QGraphicsItemGroup* frechet::view::FreeSpaceView::pathView
private

the feasible path

Definition at line 335 of file freespaceview.h.

◆ select

QGraphicsPathItem* frechet::view::FreeSpaceView::select
private

highlighted line segment (or nullptr)

Definition at line 337 of file freespaceview.h.

◆ TF_MAX_ARG

const double FreeSpaceView::TF_MAX_ARG = 1e6
static

max. value for affine transforms

Definition at line 211 of file freespaceview.h.


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