Diffstat (limited to 'inputmethods/dasher/DasherModel.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/dasher/DasherModel.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/inputmethods/dasher/DasherModel.h b/inputmethods/dasher/DasherModel.h new file mode 100644 index 0000000..348900f --- a/dev/null +++ b/inputmethods/dasher/DasherModel.h | |||
@@ -0,0 +1,111 @@ | |||
1 | // DasherModel.h | ||
2 | // | ||
3 | ///////////////////////////////////////////////////////////////////////////// | ||
4 | // | ||
5 | // Copyright (c) 2001-2002 David Ward | ||
6 | // | ||
7 | ///////////////////////////////////////////////////////////////////////////// | ||
8 | |||
9 | #ifndef __DasherModel_h__ | ||
10 | #define __DasherModel_h__ | ||
11 | |||
12 | #include <iostream> | ||
13 | #include "MSVC_Unannoy.h" | ||
14 | #include "DashEdit.h" | ||
15 | #include "DasherNode.h" | ||
16 | #include "LanguageModel.h" | ||
17 | #include "NoClones.h" | ||
18 | #include <math.h> | ||
19 | #include "DasherTypes.h" | ||
20 | #include "FrameRate.h" | ||
21 | #include <vector> | ||
22 | |||
23 | // The CDasherModel represents the current state of Dasher | ||
24 | // It contains a pointer to a structure of DasherNodes | ||
25 | // The knows the current viewpoint | ||
26 | // It also knows how to evolve the viewpoint | ||
27 | |||
28 | namespace Dasher {class CDasherModel;} | ||
29 | class Dasher::CDasherModel : private NoClones | ||
30 | { | ||
31 | public: | ||
32 | |||
33 | CDasherModel(CDashEditbox* Editbox, CLanguageModel* LanguageModel, bool Dimensions); | ||
34 | ~CDasherModel(); | ||
35 | |||
36 | // framerate functions | ||
37 | void NewFrame(unsigned long Time) {m_fr.NewFrame(Time);} // called everytime we render a new frame | ||
38 | const double Framerate () {return m_fr.Framerate();} // return the framerate | ||
39 | |||
40 | // User control of speed | ||
41 | void SetBitrate(double TargetRate) {m_fr.SetBitrate(TargetRate);} // Use or start at this bitrate | ||
42 | void SetMaxBitrate(double MaxRate) {m_fr.SetMaxBitrate(MaxRate);} // Cap any adaption at this rate | ||
43 | |||
44 | // functions returning private data (read only access) | ||
45 | const myint Rootmin() const {return m_Rootmin;} | ||
46 | const myint Rootmax() const {return m_Rootmax;} | ||
47 | const myint DasherOX() const {return m_DasherOX;} | ||
48 | CDasherNode* Root() const {return m_Root;} | ||
49 | int Normalization() const {return m_languagemodel->normalization();} | ||
50 | myint DasherY() const {return m_DasherY;} | ||
51 | bool Dimensions() const {return m_Dimensions;} | ||
52 | |||
53 | void Dump() const; // diagnostics | ||
54 | void Flush(const myint smousex,const myint smousey); // flush to the edit control | ||
55 | //void Learn_symbol(symbol Symbol) {m_languagemodel->learn_symbol(Symbol);} // feed character to language model | ||
56 | |||
57 | void Set_dimensions(bool dimensions) {m_Dimensions=dimensions;} | ||
58 | |||
59 | void Tap_on_display(myint,myint, unsigned long Time); // evolves the current viewpoint | ||
60 | void Start(); // initializes the data structure | ||
61 | void Make_root(int whichchild); // find a new root node | ||
62 | void Reparent_root(int lower, int upper); // change back to the previous root | ||
63 | void Reset_framerate(unsigned long Time) {m_fr.Reset(Time);} | ||
64 | |||
65 | CAlphabet* m_alphabet; // pointer to the alphabet | ||
66 | |||
67 | CAlphabet* GetAlphabet() { return m_alphabet; } | ||
68 | private: | ||
69 | |||
70 | // Old root notes | ||
71 | std::vector<CDasherNode*> oldroots; | ||
72 | |||
73 | // Rootmin and Rootmax specify the position of the root node in Dasher coords | ||
74 | myint m_Rootmin,m_Rootmax; | ||
75 | |||
76 | // Size of Dasher's arithmetic coding interval - it defines the Dasher coordinate system | ||
77 | myint m_DasherY; | ||
78 | |||
79 | // x position of crosshair in Dasher coords - distance from RHS is square Dasher | ||
80 | myint m_DasherOX; | ||
81 | |||
82 | // y position of crosshair in Dasher coords - distance from top in square Dasher | ||
83 | myint m_DasherOY; | ||
84 | |||
85 | // Number of input dimensions | ||
86 | bool m_Dimensions; | ||
87 | |||
88 | CDashEditbox* m_editbox; // pointer to the editbox | ||
89 | CLanguageModel* m_languagemodel; // pointer to the language model | ||
90 | CLanguageModel::CNodeContext* LearnContext; // Used to add data to model as it is entered | ||
91 | CFrameRate m_fr; // keep track of framerate | ||
92 | |||
93 | // TODO - move somewhere | ||
94 | // the probability that gets added to every symbol | ||
95 | double m_dAddProb; | ||
96 | |||
97 | CDasherNode* Get_node_under_mouse(myint smousex,myint smousey); | ||
98 | CDasherNode* Get_node_under_crosshair(); | ||
99 | CDasherNode* m_Root; | ||
100 | void Get_new_root_coords(myint mousex,myint mousey); | ||
101 | void Get_string_under_mouse(const myint smousex,const myint smousey,std::vector<symbol> &str); | ||
102 | void Update(CDasherNode* node,CDasherNode* under,int safe); | ||
103 | |||
104 | |||
105 | |||
106 | |||
107 | |||
108 | }; | ||
109 | |||
110 | |||
111 | #endif /* #ifndef __DasherModel_h__ */ | ||