Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
frechet::app::FrechetViewApplication Class Reference

Detailed Description

the application singleton

Manages all central concerns of the Qt application

FrechetViewApplication is responsible for setting up the GUI, opening files, starting and stopping algorithms, managing data structures, and some more...

Usually such a class would be derived from QGuiApplication. We have chosen another approach, with QApplication being a separate object. This allows to run FrechetViewApplication either with a GUI, or head-less as a command-line application.

See also
main.cpp
Author
Peter Schäfer

Definition at line 43 of file frechetviewapplication.h.

#include <frechetviewapplication.h>

Inherits QObject.

Public Types

enum  Algorithm { ALGORITHM_CURVE =0, ALGORITHM_POLYGON =1, ALGORITHM_K_FRECHET =2 }
 we have three Fréchet Distance algorithms More...
 
enum  TriState { NO, YES, DEFAULT }
 GPU support (for headless mode only) More...
 

Public Slots

void open (bool firstTime=false)
 initialises the GUI More...
 
void open (QString filePath)
 initialises the GUI and opens a file More...
 
static FrechetViewApplicationinstance ()
 
void quit ()
 quit the application, closing all resources and windows More...
 
void windowClosed (QMainWindow *)
 called when the main window is closed by the user More...
 
Grid::ptr getGrid ()
 
FreeSpace::ptr getFreeSpace ()
 
FSPath::ptr getFSPath ()
 
kAlgorithm::ptr getKAlgorithm ()
 
poly::Algorithm::ptr getPolyAlgorithm ()
 
CurvegetP ()
 
CurvegetQ ()
 
void resetAlgorithms ()
 stops running algorithm(s) More...
 
void showAboutDialog ()
 opens the "About" dialog More...
 
void createDesktopEntry ()
 creates an application icon on the users desktop More...
 
void editInputFile ()
 opens the input file in an editor More...
 
void startStopDecidePolygon ()
 starts, or stops the decision algorithm for simple polygons More...
 
void startStopOptimiseCurve ()
 starts, or stops the optimisation algorithm for curves More...
 
void startStopApproximateCurve ()
 starts, or stops the approximation algorithm for curves More...
 
void startStopOptimisePolygon ()
 starts, or stops the optimisation algorithm for simple polygons More...
 
void startStopApproximatePolygon ()
 starts, or stops the approximation algorithm for simple polygons More...
 
void startKBruteForce ()
 starts the brute-force k-Frechet algorithm More...
 
void cancelBackgroundJob ()
 stops long-running algorithm (if necessary) More...
 

Signals

void fileOpened (QString file)
 raised when a new file is opened. Triggers changes in all parts of the GUI. More...
 
void algorithmChanged (int algo)
 raised when another algorithm is selected. Triggers changes in all parts of the GUI. More...
 

Public Member Functions

 FrechetViewApplication (QString exec_path, bool withGui)
 default constructor More...
 
 ~FrechetViewApplication ()
 desctructor; closes all resources and windows More...
 
void init (QString file)
 initialise the GUI application and open a file (optional) More...
 
int commandLineInterface (QString inputFile, Algorithm algo, bool topo, double accuracy, double epsilon) throw (std::exception)
 run the command line interface More...
 
Algorithm currentAlgorithm () const
 
bool currentAlgorithm (Algorithm alg) const
 test current algorithm More...
 
void setCurrentAlgorithm (Algorithm alg)
 change current algorithm More...
 
WorkerJobHandlebackgroundJob ()
 

Protected Attributes

FileHistory history
 Open Recent file history. More...
 
size_t currentId
 reference to current File More...
 
InputReader reader
 reads files from disk More...
 
DataPath path
 pointer to input data within an xml file More...
 
QFileSystemWatcher * fileWatch
 
Curve P
 first input curve More...
 
Curve Q
 
Grid::ptr grid
 manages the free-space grid More...
 
FreeSpace::ptr freeSpace
 the free-space diagram More...
 
Algorithm _currentAlgorithm
 selects current Algorithm More...
 
FSPath::ptr fspath
 the feasible path (if available) More...
 
k::kAlgorithm::ptr kAlgorithm
 the k-Frechet algorithm (if available) More...
 
poly::Algorithm::ptr polyAlgorithm
 the algorithm for simple polygons and curves (if available) More...
 
WorkerJobHandle bgJob
 
double epsMax
 maximum value for epsilon More...
 
MainWindowwindow
 the main window More...
 

Static Protected Attributes

static FrechetViewApplicationfrechetViewApp = nullptr
 singleton instance More...
 

Private Member Functions

void saveFileSettings (QSettings &settings, size_t histId)
 save file specific settings to preferences More...
 
void restoreFileSettings (QSettings &settings, size_t histId)
 read file specific settings from preferences More...
 
bool showFirstTimeHint ()
 show a short hint when the application is opened for the very first time More...
 
bool setupCurves (bool topo=false)
 set up geometric data structures, like triangulations etc. More...
 
void startStopDecidePolygon (double epsilon)
 start or stop decision algorithm for simple polygons More...
 
void startStopOptimiseCurve (double approx)
 start or stop algorithm for curves More...
 
void startStopOptimisePolygon (double approx)
 start or stop algorithm for simple polygons More...
 
void installLinuxDesktopIcons (QSettings &)
 create a desktop icon on a Linux system (or try at least..) More...
 
void installLinuxDesktopEntries (QSettings &)
 create a desktop file on a Linux system (or try at least..) More...
 
QString linuxDesktopFile ()
 find location of desktpo file More...
 
bool populateBookmarks ()
 for presentation mode only More...
 
void cli_setup (QString inputFile, Algorithm algo)
 prepare the application for command line mode More...
 
int cli_decideKFrechet (double epsilon)
 run the k-Frechet brute-force algorithm in headless mode More...
 

Static Private Member Functions

static void copyContents (QByteArray contents, QString path)
 copy data to a file on disk More...
 
static void copyFile (QString src, QString dest)
 copy files on disk More...
 

Private Attributes

QString execPath
 path to executable file More...
 

Member Enumeration Documentation

◆ Algorithm

we have three Fréchet Distance algorithms

Enumerator
ALGORITHM_CURVE 

compute "classical" Fréchet distance between two polygonal curves

ALGORITHM_POLYGON 

compute Fréchet distance between simple polygons

ALGORITHM_K_FRECHET 

compute k-Fréchet distance between two curves

Definition at line 51 of file frechetviewapplication.h.

◆ TriState

GPU support (for headless mode only)

Enumerator
NO 

no GPU

YES 

GPU required.

DEFAULT 

default = use GPU, if available

Definition at line 64 of file frechetviewapplication.h.

Constructor & Destructor Documentation

◆ FrechetViewApplication()

FrechetViewApplication::FrechetViewApplication ( QString  exec_path,
bool  withGui 
)

default constructor

Parameters
exec_pathpath to executable file
withGuiset up GUI, or run head-less

Definition at line 29 of file frechetviewapplication.cpp.

◆ ~FrechetViewApplication()

FrechetViewApplication::~FrechetViewApplication ( )

desctructor; closes all resources and windows

Definition at line 53 of file frechetviewapplication.cpp.

Member Function Documentation

◆ algorithmChanged

void frechet::app::FrechetViewApplication::algorithmChanged ( int  algo)
signal

raised when another algorithm is selected. Triggers changes in all parts of the GUI.

Parameters
algoint algorithm (of type Algorithm)

◆ backgroundJob()

WorkerJobHandle* frechet::app::FrechetViewApplication::backgroundJob ( )
inline
Returns
a handle to the current background job, or nullptr

Definition at line 158 of file frechetviewapplication.h.

◆ cancelBackgroundJob

void FrechetViewApplication::cancelBackgroundJob ( )
slot

stops long-running algorithm (if necessary)

Definition at line 481 of file frechetviewapplication.cpp.

◆ cli_decideKFrechet()

int FrechetViewApplication::cli_decideKFrechet ( double  epsilon)
private

run the k-Frechet brute-force algorithm in headless mode

Parameters
epsilon
Returns
optimal k, or < 0 if no solution is found

Definition at line 38 of file cli.cpp.

◆ cli_setup()

void FrechetViewApplication::cli_setup ( QString  inputFile,
Algorithm  algo 
)
private

prepare the application for command line mode

Parameters
inputFileinput file
algoalgorithm to perform

Definition at line 12 of file cli.cpp.

◆ commandLineInterface()

int FrechetViewApplication::commandLineInterface ( QString  inputFile,
Algorithm  algo,
bool  topo,
double  accuracy,
double  epsilon 
)
throw (std::exception
)

run the command line interface

Parameters
inputFilefile to process
algoselect an algorithm
topoparameter to poly algorithm: process matrixes in topological order, saving memory
accuracyparameter to approximation algorithms
epsilonepsilon for the decision variant
Exceptions
std::exceptionif there is an error in the input, or parameters are not correct
Returns
0 if successful

Definition at line 68 of file cli.cpp.

◆ copyContents()

void FrechetViewApplication::copyContents ( QByteArray  contents,
QString  path 
)
staticprivate

copy data to a file on disk

Definition at line 604 of file frechetviewapplication.cpp.

◆ copyFile()

void FrechetViewApplication::copyFile ( QString  src,
QString  dest 
)
staticprivate

copy files on disk

Definition at line 613 of file frechetviewapplication.cpp.

◆ createDesktopEntry

void FrechetViewApplication::createDesktopEntry ( )
slot

creates an application icon on the users desktop

Definition at line 366 of file frechetviewapplication.cpp.

◆ currentAlgorithm() [1/2]

Algorithm frechet::app::FrechetViewApplication::currentAlgorithm ( ) const
inline
Returns
the currently selected algorithm

Definition at line 143 of file frechetviewapplication.h.

◆ currentAlgorithm() [2/2]

bool frechet::app::FrechetViewApplication::currentAlgorithm ( Algorithm  alg) const
inline

test current algorithm

Parameters
algan algorithm
Returns
true if current algorithm is equal to 'alg'

Definition at line 149 of file frechetviewapplication.h.

◆ editInputFile

void FrechetViewApplication::editInputFile ( )
slot

opens the input file in an editor

Definition at line 400 of file frechetviewapplication.cpp.

◆ fileOpened

void frechet::app::FrechetViewApplication::fileOpened ( QString  file)
signal

raised when a new file is opened. Triggers changes in all parts of the GUI.

Parameters
filefile name

◆ getFreeSpace

FreeSpace::ptr frechet::app::FrechetViewApplication::getFreeSpace ( )
inlineslot
Returns
the free-space diagram

Definition at line 211 of file frechetviewapplication.h.

◆ getFSPath

FSPath::ptr frechet::app::FrechetViewApplication::getFSPath ( )
inlineslot
Returns
the feasible path (if available)

Definition at line 213 of file frechetviewapplication.h.

◆ getGrid

Grid::ptr frechet::app::FrechetViewApplication::getGrid ( )
inlineslot
Returns
the free-space grid

Definition at line 209 of file frechetviewapplication.h.

◆ getKAlgorithm

kAlgorithm::ptr frechet::app::FrechetViewApplication::getKAlgorithm ( )
inlineslot
Returns
the k-Frechet algorith (if available)

Definition at line 215 of file frechetviewapplication.h.

◆ getP

Curve& frechet::app::FrechetViewApplication::getP ( )
inlineslot
Returns
the first input curve

Definition at line 220 of file frechetviewapplication.h.

◆ getPolyAlgorithm

poly::Algorithm::ptr frechet::app::FrechetViewApplication::getPolyAlgorithm ( )
inlineslot
Returns
the poly-algorithm (if available)

Definition at line 217 of file frechetviewapplication.h.

◆ getQ

Curve& frechet::app::FrechetViewApplication::getQ ( )
inlineslot
Returns
the second input curve

Definition at line 222 of file frechetviewapplication.h.

◆ init()

void FrechetViewApplication::init ( QString  file)

initialise the GUI application and open a file (optional)

Parameters
filefile to open (optional, may be empty)

Definition at line 60 of file frechetviewapplication.cpp.

◆ installLinuxDesktopEntries()

void FrechetViewApplication::installLinuxDesktopEntries ( QSettings &  )
private

create a desktop file on a Linux system (or try at least..)

Definition at line 509 of file frechetviewapplication.cpp.

◆ installLinuxDesktopIcons()

void FrechetViewApplication::installLinuxDesktopIcons ( QSettings &  )
private

create a desktop icon on a Linux system (or try at least..)

Definition at line 487 of file frechetviewapplication.cpp.

◆ instance

static FrechetViewApplication* frechet::app::FrechetViewApplication::instance ( )
inlinestaticslot
Returns
singleton instance

Definition at line 188 of file frechetviewapplication.h.

◆ linuxDesktopFile()

QString FrechetViewApplication::linuxDesktopFile ( )
private

find location of desktpo file

Definition at line 522 of file frechetviewapplication.cpp.

◆ open [1/2]

void frechet::app::FrechetViewApplication::open ( bool  firstTime = false)
slot

initialises the GUI

Parameters
firstTimeshow user hint when no file is opened (optional)

◆ open [2/2]

void FrechetViewApplication::open ( QString  filePath)
slot

initialises the GUI and opens a file

Parameters
filePathabsolute path to file

Definition at line 205 of file frechetviewapplication.cpp.

◆ populateBookmarks()

bool FrechetViewApplication::populateBookmarks ( )
private

for presentation mode only

Definition at line 554 of file frechetviewapplication.cpp.

◆ quit

void frechet::app::FrechetViewApplication::quit ( )
inlineslot

quit the application, closing all resources and windows

Definition at line 194 of file frechetviewapplication.h.

◆ resetAlgorithms

void FrechetViewApplication::resetAlgorithms ( )
slot

stops running algorithm(s)

Definition at line 168 of file frechetviewapplication.cpp.

◆ restoreFileSettings()

void FrechetViewApplication::restoreFileSettings ( QSettings &  settings,
size_t  histId 
)
private

read file specific settings from preferences

Parameters
settingsapplication preferences
histIdID in file history

Definition at line 632 of file frechetviewapplication.cpp.

◆ saveFileSettings()

void FrechetViewApplication::saveFileSettings ( QSettings &  settings,
size_t  histId 
)
private

save file specific settings to preferences

Parameters
settingsapplication preferences
histIdID in file history

Definition at line 621 of file frechetviewapplication.cpp.

◆ setCurrentAlgorithm()

void FrechetViewApplication::setCurrentAlgorithm ( FrechetViewApplication::Algorithm  alg)

change current algorithm

Parameters
algnew algorithm

Clears the feasible path and triggers the signal algorithmChanged(). This signal will cause subsequent changes to several parts of the GUI, like the control panel, the curve view, etc.

Definition at line 141 of file frechetviewapplication.cpp.

◆ setupCurves()

bool FrechetViewApplication::setupCurves ( bool  topo = false)
private

set up geometric data structures, like triangulations etc.

Parameters
topo
Returns
true if successful

Definition at line 646 of file frechetviewapplication.cpp.

◆ showAboutDialog

void FrechetViewApplication::showAboutDialog ( )
slot

opens the "About" dialog

Definition at line 356 of file frechetviewapplication.cpp.

◆ showFirstTimeHint()

bool FrechetViewApplication::showFirstTimeHint ( )
private

show a short hint when the application is opened for the very first time

Returns
true if successful

Definition at line 733 of file frechetviewapplication.cpp.

◆ startKBruteForce

void FrechetViewApplication::startKBruteForce ( )
slot

starts the brute-force k-Frechet algorithm

Definition at line 474 of file frechetviewapplication.cpp.

◆ startStopApproximateCurve

void FrechetViewApplication::startStopApproximateCurve ( )
slot

starts, or stops the approximation algorithm for curves

Definition at line 456 of file frechetviewapplication.cpp.

◆ startStopApproximatePolygon

void FrechetViewApplication::startStopApproximatePolygon ( )
slot

starts, or stops the approximation algorithm for simple polygons

Definition at line 434 of file frechetviewapplication.cpp.

◆ startStopDecidePolygon [1/2]

void FrechetViewApplication::startStopDecidePolygon ( )
slot

starts, or stops the decision algorithm for simple polygons

Definition at line 409 of file frechetviewapplication.cpp.

◆ startStopDecidePolygon() [2/2]

void FrechetViewApplication::startStopDecidePolygon ( double  epsilon)
private

start or stop decision algorithm for simple polygons

Parameters
epsilon

Definition at line 415 of file frechetviewapplication.cpp.

◆ startStopOptimiseCurve [1/2]

void FrechetViewApplication::startStopOptimiseCurve ( )
slot

starts, or stops the optimisation algorithm for curves

Definition at line 451 of file frechetviewapplication.cpp.

◆ startStopOptimiseCurve() [2/2]

void FrechetViewApplication::startStopOptimiseCurve ( double  approx)
private

start or stop algorithm for curves

Parameters
approxif > 0, run approximation algorithm. if ==0, run optimisation algorithm.

Definition at line 462 of file frechetviewapplication.cpp.

◆ startStopOptimisePolygon [1/2]

void FrechetViewApplication::startStopOptimisePolygon ( )
slot

starts, or stops the optimisation algorithm for simple polygons

Definition at line 429 of file frechetviewapplication.cpp.

◆ startStopOptimisePolygon() [2/2]

void FrechetViewApplication::startStopOptimisePolygon ( double  approx)
private

start or stop algorithm for simple polygons

Parameters
approxif > 0, run approximation algorithm. if ==0, run optimisation algorithm.

Definition at line 440 of file frechetviewapplication.cpp.

◆ windowClosed

void frechet::app::FrechetViewApplication::windowClosed ( QMainWindow *  )
inlineslot

called when the main window is closed by the user

Definition at line 201 of file frechetviewapplication.h.

Member Data Documentation

◆ _currentAlgorithm

Algorithm frechet::app::FrechetViewApplication::_currentAlgorithm
protected

selects current Algorithm

Definition at line 94 of file frechetviewapplication.h.

◆ bgJob

WorkerJobHandle frechet::app::FrechetViewApplication::bgJob
protected

long-running job. some algorithms take long and are delegated to a background thread.

Definition at line 103 of file frechetviewapplication.h.

◆ currentId

size_t frechet::app::FrechetViewApplication::currentId
protected

reference to current File

Definition at line 77 of file frechetviewapplication.h.

◆ epsMax

double frechet::app::FrechetViewApplication::epsMax
protected

maximum value for epsilon

Definition at line 105 of file frechetviewapplication.h.

◆ execPath

QString frechet::app::FrechetViewApplication::execPath
private

path to executable file

Definition at line 252 of file frechetviewapplication.h.

◆ fileWatch

QFileSystemWatcher* frechet::app::FrechetViewApplication::fileWatch
protected

keeps track of changed files on disk. If the current file changes on disk, it will be automatically reloaded.

Definition at line 85 of file frechetviewapplication.h.

◆ frechetViewApp

FrechetViewApplication * FrechetViewApplication::frechetViewApp = nullptr
staticprotected

singleton instance

Definition at line 72 of file frechetviewapplication.h.

◆ freeSpace

FreeSpace::ptr frechet::app::FrechetViewApplication::freeSpace
protected

the free-space diagram

Definition at line 92 of file frechetviewapplication.h.

◆ fspath

FSPath::ptr frechet::app::FrechetViewApplication::fspath
protected

the feasible path (if available)

Definition at line 96 of file frechetviewapplication.h.

◆ grid

Grid::ptr frechet::app::FrechetViewApplication::grid
protected

manages the free-space grid

Definition at line 90 of file frechetviewapplication.h.

◆ history

FileHistory frechet::app::FrechetViewApplication::history
protected

Open Recent file history.

Definition at line 75 of file frechetviewapplication.h.

◆ kAlgorithm

k::kAlgorithm::ptr frechet::app::FrechetViewApplication::kAlgorithm
protected

the k-Frechet algorithm (if available)

Definition at line 98 of file frechetviewapplication.h.

◆ P

Curve frechet::app::FrechetViewApplication::P
protected

first input curve

Definition at line 87 of file frechetviewapplication.h.

◆ path

DataPath frechet::app::FrechetViewApplication::path
protected

pointer to input data within an xml file

Definition at line 82 of file frechetviewapplication.h.

◆ polyAlgorithm

poly::Algorithm::ptr frechet::app::FrechetViewApplication::polyAlgorithm
protected

the algorithm for simple polygons and curves (if available)

Definition at line 100 of file frechetviewapplication.h.

◆ Q

Curve frechet::app::FrechetViewApplication::Q
protected

second input curve

Definition at line 88 of file frechetviewapplication.h.

◆ reader

InputReader frechet::app::FrechetViewApplication::reader
protected

reads files from disk

Definition at line 80 of file frechetviewapplication.h.

◆ window

MainWindow* frechet::app::FrechetViewApplication::window
protected

the main window

Definition at line 107 of file frechetviewapplication.h.


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