Copiste  0.1
 All Classes Functions Variables Enumerations Friends Pages
editor.h
1 /*
2  * This file is part of Copiste.
3  *
4  * Copiste is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Copiste is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Copiste. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 #ifndef INCLUDED_EDITORH
20 #define INCLUDED_EDITORH
21 
22 #include <QMainWindow>
23 #include <QStatusBar>
24 #include <QMenuBar>
25 #include <QToolBar>
26 #include <QFileDialog>
27 
28 // Settings dialog
29 #include <QSpinBox>
30 #include <QDoubleSpinBox>
31 #include <QVBoxLayout>
32 #include <QHBoxLayout>
33 #include <QLabel>
34 #include <QPushButton>
35 #include <QCheckBox>
36 
37 class Editor;
38 
39 #include "gui/view2D.h"
40 #include "algo/neuralnetwork.h"
41 #include "algo/corpus.h"
42 
44 class SettingsDialog : public QDialog
45 {
46  Q_OBJECT
47  public:
48  SettingsDialog(double rate, double reg, int iter, bool debug, QWidget *parent = 0);
49 
50  public slots:
51  void emitValues();
52  signals:
53  void values(double rate, double reg, int iter, bool debug);
54 
55  private:
56  QDoubleSpinBox mRate, mReg;
57  QSpinBox mIter;
58  QCheckBox mDebug;
59 };
60 
62 class Editor : public QMainWindow
63 {
64  Q_OBJECT
65  public:
66  Editor(QWidget *parent = 0);
67 
68  void setNet(NeuralNetwork *net);
69  void setCorpus(Corpus *corpus);
70 
71  void setRegularization(double r);
72  void setTrainingRate(double r);
73  void setIter(int iter);
74  void setDebug(bool debug);
75 
76  protected:
77  void keyReleaseEvent(QKeyEvent *event);
78 
79  public slots:
80  void dispRendering();
81  void dispRendered();
82  void dispMessage(std::string message);
83  void handleRequest(QAction *action);
84  void updateSettings(double rate, double reg, int iter, bool debug);
85 
86  private:
87  View2D mView;
88  QToolBar *mToolbar;
89 
90  // Training parameters
91  double mTrainingRate, mRegularization;
92  int mIter;
93  bool mDebug;
94 };
95 
96 #endif