Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
controlpanel.h
Go to the documentation of this file.
1 #ifndef CONTROLPANEL_H
2 #define CONTROLPANEL_H
3 
4 #include <QLineEdit>
5 #include <QSlider>
6 #include <QDoubleValidator>
7 #include <QSettings>
8 
9 #include <types.h>
10 #include <interval.h>
11 #include <k_frechet/kalgorithm.h>
12 
13 #include "ui_controlpanel.h"
14 
15 namespace frechet { namespace view {
23 class ControlPanel: public QWidget
24 {
25  Q_OBJECT
26  Q_PROPERTY(double epsilon READ getEpsilon WRITE setEpsilonWithNotify)
27 
28 public:
33  ControlPanel(QWidget* parent=0);
34 
36  double getEpsilon() { return eps; }
37  // @see FrechetViewApplication::Algorithm
38 
44  void saveSettings(QSettings& settings, QString group);
50  void restoreSettings(QSettings& settings, QString group);
51 
52 signals:
59  void epsilonChanged(double eps);
60 
65  void showGreedyResult();
70  void showOptimalResult();
75  void hideResult();
76 
77 public slots:
79  void lockInput(bool) { /*TODO*/ }
80 
85  void onEdit();
91  void onSlider(int value);
97  void onAlgorithmChanged(int algorithm);
98 
103  void onGreedyButton();
108  void onBFButton();
109 
116  void setEpsilon(double eps, bool notify);
121  void setEpsilonWithoutNotify(double eps) { setEpsilon(eps,false);}
126  void setEpsilonWithNotify(double eps) { setEpsilon(eps,true);}
131  void setEpsilonMax(double eps_max);
132 
134  void updateResults();
136  void clearResults();
137 
139  void updatePolyResult();
140 
142  void onShowBounds(bool);
143 
145  void onCurveFinished(bool);
146 
147 private:
150  void updateGreedyResult(const k::kAlgorithm::Greedy& kalg);
155 
162 
163 private:
165  static const int DECIMALS;
166 
168  double eps;
170  QLocale locale;
172  QDoubleValidator* epsValidator;
174  double eps_step;
175 
177  Ui::ControlPanel ui;
178 
182  QString toString(double x);
186  double toDouble(QString text);
187 
191  int toSliderValue(double x);
195  double fromSliderValue(int i);
196 
203  void showIcon(QLabel* label, int status);
210  void setIcon(QLabel* label, QString text, QString tooltip="");
211 
213  static QMovie* loaderMovie;
215  QLabel* movieLabel;
218 
220  static QString POLY_STATUS [];
221 
222 protected:
223  void wheelEvent(QWheelEvent *) override;
224  void keyPressEvent(QKeyEvent *event) override;
225 };
230 void singleStep(QAbstractSlider*, double factor);
235 void pageStep(QAbstractSlider*, double factor);
236 
237 } } // namespace
238 
239 #endif // CONTROLPANEL_H
static const int DECIMALS
number of decimals in the epsilon control
Definition: controlpanel.h:165
void onCurveFinished(bool)
called when the curve algorithm finishes; update the "curve" panel to show latest results
void singleStep(QAbstractSlider *, double factor)
perform a single step on a slider
Definition: baseview.cpp:158
static QString POLY_STATUS[]
texts to display for algorithm results
Definition: controlpanel.h:220
ControlPanel(QWidget *parent=0)
default constructor
void updateGreedyResult(const k::kAlgorithm::Greedy &kalg)
update results of the k-Frechet greedy algorithm
void setEpsilonWithoutNotify(double eps)
update the value of epsilon without raising signals
Definition: controlpanel.h:121
void onBFButton()
called when the user clicks the "Show" button in the "brute-force" section. Triggers showOptimalResul...
global definitions for all algorithms.
int toSliderValue(double x)
map an epsilon value to a slider location
QString toString(double x)
format a number for display, with appropriate locale
Results of the Greedy algorithm.
Definition: kalgorithm.h:207
void onEdit()
called after the user has edited the value of epsilon. Triggers epsilonChanged(), which in turn trigg...
QLabel * movieLabel
label that display the rotating icon
Definition: controlpanel.h:215
void showIcon(QLabel *label, int status)
show a status icon in the control panel
void onGreedyButton()
called when the user clicks the "Show" button in the "greedy" section. Triggers showGreedyResult(),...
double fromSliderValue(int i)
map a slider location to a value of epsilon
void pageStep(QAbstractSlider *, double factor)
perform a page step on a slider
Definition: baseview.cpp:163
void updatePolyResult()
update the "Polygon" pabel to show the lastest results of the poly-algorithm
void onShowBounds(bool)
called when the user clicks the "Show Bounds" button
double eps
the current value of epsilon
Definition: controlpanel.h:168
void onAlgorithmChanged(int algorithm)
called when the user selects a algorithm panel. Calls on FrechetViewApplication to update the current...
void lockInput(bool)
not used anymore...
Definition: controlpanel.h:79
double eps_step
step size for epsilon slider control
Definition: controlpanel.h:174
static QMovie * loaderMovie
displays a rotatin icon (during a long-running algorithm)
Definition: controlpanel.h:213
void setEpsilon(double eps, bool notify)
updates the value of epsilon
void setEpsilonWithNotify(double eps)
update the value of epsilon and raise signals
Definition: controlpanel.h:126
bool curve_was_ok
latest result of the decision algorithm for curves
Definition: controlpanel.h:217
void saveSettings(QSettings &settings, QString group)
store settings to application preferences
void setIcon(QLabel *label, QString text, QString tooltip="")
show a status icon in the control panel
void updateOptimalResult(const k::kAlgorithm::BruteForce &bfres)
update results of the k-Frechet brute-force algorithm
void restoreSettings(QSettings &settings, QString group)
load settings from application preferences
Ui::ControlPanel ui
UI elements (auto-generated by Qt)
Definition: controlpanel.h:177
results of the brute-force algorithm
Definition: kalgorithm.h:258
void clearResults()
reset the k-Frechet panel
void showOptimalResult()
raised when the user clicks the "Show" button in the k-Frechet panel. Updates the free-space diagram ...
QDoubleValidator * epsValidator
validator for epsilon input
Definition: controlpanel.h:172
void wheelEvent(QWheelEvent *) override
Result
negative values for k indicate the special conditions of the computation
Definition: kalgorithm.h:131
QLocale locale
locale used for number formatting
Definition: controlpanel.h:170
void epsilonChanged(double eps)
raised when the value of epsilon changes (e.g. when the user operates the slider control)....
void onSlider(int value)
called when the user moves the slider control for epsilon. Triggers epsilonChanged(),...
void keyPressEvent(QKeyEvent *event) override
void hideResult()
raised when the user clicks the "Hide" button in the k-Frechet panel. Resets the free-space diagram t...
double toDouble(QString text)
parse a number input
void updateResults()
update the k-Frechet panel to show the latest results of the k-Frechet algorithm
void setEpsilonMax(double eps_max)
update the maximum value of epsilon; adjusts the slider control
void showGreedyResult()
raised when the user clicks the "Show" button in the k-Frechet panel. Updates the free-space diagram ...