Diffstat (limited to 'inputmethods/dasher/DasherNode.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/dasher/DasherNode.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/inputmethods/dasher/DasherNode.cpp b/inputmethods/dasher/DasherNode.cpp index 26af10f..3a984ef 100644 --- a/inputmethods/dasher/DasherNode.cpp +++ b/inputmethods/dasher/DasherNode.cpp | |||
@@ -1,131 +1,131 @@ | |||
1 | // DasherNode.cpp | 1 | // DasherNode.cpp |
2 | // | 2 | // |
3 | ///////////////////////////////////////////////////////////////////////////// | 3 | ///////////////////////////////////////////////////////////////////////////// |
4 | // | 4 | // |
5 | // Copyright (c) 2001-2002 David Ward | 5 | // Copyright (c) 2001-2002 David Ward |
6 | // | 6 | // |
7 | ///////////////////////////////////////////////////////////////////////////// | 7 | ///////////////////////////////////////////////////////////////////////////// |
8 | 8 | ||
9 | #include "DasherNode.h" | 9 | #include "DasherNode.h" |
10 | using namespace Dasher; | 10 | using namespace Dasher; |
11 | using namespace Opts; | 11 | using namespace Opts; |
12 | using namespace std; | 12 | using namespace std; |
13 | 13 | ||
14 | ///////////////////////////////////////////////////////////////////////////// | 14 | ///////////////////////////////////////////////////////////////////////////// |
15 | 15 | ||
16 | void CDasherNode::Dump_node () const | 16 | void CDasherNode::Dump_node () const |
17 | { | 17 | { |
18 | /* TODO sort out | 18 | /* TODO sort out |
19 | dchar out[256]; | 19 | dchar out[256]; |
20 | if (m_Symbol) | 20 | if (m_Symbol) |
21 | wsprintf(out,TEXT("%7x %3c %7x %5d %7x %5d %8x %8x \n"),this,m_Symbol,m_iGroup,m_context,m_Children,m_Cscheme,m_iLbnd,m_iHbnd); | 21 | wsprintf(out,TEXT("%7x %3c %7x %5d %7x %5d %8x %8x \n"),this,m_Symbol,m_iGroup,m_context,m_Children,m_Cscheme,m_iLbnd,m_iHbnd); |
22 | else | 22 | else |
23 | wsprintf(out,TEXT("%7x %7x %5d %7x %5d %8x %8x \n"),this,m_iGroup,m_context,m_Children,m_Cscheme,m_iLbnd,m_iHbnd); | 23 | wsprintf(out,TEXT("%7x %7x %5d %7x %5d %8x %8x \n"),this,m_iGroup,m_context,m_Children,m_Cscheme,m_iLbnd,m_iHbnd); |
24 | 24 | ||
25 | OutputDebugString(out); | 25 | OutputDebugString(out); |
26 | 26 | ||
27 | if (m_Children) { | 27 | if (m_Children) { |
28 | unsigned int i; | 28 | unsigned int i; |
29 | for (i=1;i<m_iChars;i++) | 29 | for (i=1;i<m_iChars;i++) |
30 | m_Children[i]->Dump_node(); | 30 | m_Children[i]->Dump_node(); |
31 | } | 31 | } |
32 | */ | 32 | */ |
33 | } | 33 | } |
34 | 34 | ||
35 | void CDasherNode::Generic_Push_Node(CLanguageModel::CNodeContext *context) { | 35 | void CDasherNode::Generic_Push_Node(CLanguageModel::CNodeContext *) { |
36 | 36 | ||
37 | m_iAge=0; | 37 | m_iAge=0; |
38 | m_bAlive=true; | 38 | m_bAlive=true; |
39 | if (m_Symbol && !m_iChars) // make sure it's a valid symbol and don't enter if already done | 39 | if (m_Symbol && !m_iChars) // make sure it's a valid symbol and don't enter if already done |
40 | m_languagemodel->EnterNodeSymbol(m_context,m_Symbol); | 40 | m_languagemodel->EnterNodeSymbol(m_context,m_Symbol); |
41 | 41 | ||
42 | 42 | ||
43 | vector<symbol> newchars; // place to put this list of characters | 43 | vector<symbol> newchars; // place to put this list of characters |
44 | vector<unsigned int> cum,groups; // for the probability list | 44 | vector<unsigned int> cum,groups; // for the probability list |
45 | m_languagemodel->GetNodeProbs(m_context,newchars,groups,cum,0.003); | 45 | m_languagemodel->GetNodeProbs(m_context,newchars,groups,cum,0.003); |
46 | m_iChars=newchars.size(); | 46 | m_iChars=newchars.size(); |
47 | // work out cumulative probs | 47 | // work out cumulative probs |
48 | unsigned int i; | 48 | unsigned int i; |
49 | for (i=1;i<m_iChars;i++) | 49 | for (i=1;i<m_iChars;i++) |
50 | cum[i]+=cum[i-1]; | 50 | cum[i]+=cum[i-1]; |
51 | 51 | ||
52 | m_Children =new CDasherNode *[m_iChars]; | 52 | m_Children =new CDasherNode *[m_iChars]; |
53 | 53 | ||
54 | // create the children | 54 | // create the children |
55 | ColorSchemes NormalScheme, SpecialScheme; | 55 | ColorSchemes NormalScheme, SpecialScheme; |
56 | if ((m_ColorScheme==Nodes1) || (m_ColorScheme==Special1)) { | 56 | if ((m_ColorScheme==Nodes1) || (m_ColorScheme==Special1)) { |
57 | NormalScheme = Nodes2; | 57 | NormalScheme = Nodes2; |
58 | SpecialScheme = Special2; | 58 | SpecialScheme = Special2; |
59 | } else { | 59 | } else { |
60 | NormalScheme = Nodes1; | 60 | NormalScheme = Nodes1; |
61 | SpecialScheme = Special1; | 61 | SpecialScheme = Special1; |
62 | } | 62 | } |
63 | 63 | ||
64 | ColorSchemes ChildScheme; | 64 | ColorSchemes ChildScheme; |
65 | for (i=1;i<m_iChars;i++) { | 65 | for (i=1;i<m_iChars;i++) { |
66 | if (newchars[i]==this->m_languagemodel->GetSpaceSymbol()) | 66 | if (newchars[i]==this->m_languagemodel->GetSpaceSymbol()) |
67 | ChildScheme = SpecialScheme; | 67 | ChildScheme = SpecialScheme; |
68 | else | 68 | else |
69 | ChildScheme = NormalScheme; | 69 | ChildScheme = NormalScheme; |
70 | m_Children[i]=new CDasherNode(this,newchars[i],groups[i],i,ChildScheme,cum[i-1],cum[i],m_languagemodel,m_languagemodel->GetColour(i)); | 70 | m_Children[i]=new CDasherNode(this,newchars[i],groups[i],i,ChildScheme,cum[i-1],cum[i],m_languagemodel,m_languagemodel->GetColour(i)); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | ///////////////////////////////////////////////////////////////////////////// | 74 | ///////////////////////////////////////////////////////////////////////////// |
75 | 75 | ||
76 | void CDasherNode::Push_Node(CLanguageModel::CNodeContext *context) | 76 | void CDasherNode::Push_Node(CLanguageModel::CNodeContext *context) |
77 | // push a node copying the specified context | 77 | // push a node copying the specified context |
78 | { | 78 | { |
79 | 79 | ||
80 | if (m_Children) { | 80 | if (m_Children) { |
81 | // if there are children just give them a poke | 81 | // if there are children just give them a poke |
82 | unsigned int i; | 82 | unsigned int i; |
83 | for (i=1;i<m_iChars;i++) { | 83 | for (i=1;i<m_iChars;i++) { |
84 | m_Children[i]->m_iAge=0; | 84 | m_Children[i]->m_iAge=0; |
85 | m_Children[i]->m_bAlive=1; | 85 | m_Children[i]->m_bAlive=1; |
86 | } | 86 | } |
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | 89 | ||
90 | // if we haven't got a context then try to get a new one | 90 | // if we haven't got a context then try to get a new one |
91 | m_context=m_languagemodel->CloneNodeContext(context); | 91 | m_context=m_languagemodel->CloneNodeContext(context); |
92 | // if it fails, be patient | 92 | // if it fails, be patient |
93 | if (!m_context) | 93 | if (!m_context) |
94 | return; | 94 | return; |
95 | Generic_Push_Node(m_context); | 95 | Generic_Push_Node(m_context); |
96 | } | 96 | } |
97 | 97 | ||
98 | ///////////////////////////////////////////////////////////////////////////// | 98 | ///////////////////////////////////////////////////////////////////////////// |
99 | 99 | ||
100 | void CDasherNode::Push_Node() | 100 | void CDasherNode::Push_Node() |
101 | { | 101 | { |
102 | 102 | ||
103 | if (m_Children) { | 103 | if (m_Children) { |
104 | // if there are children just give them a poke | 104 | // if there are children just give them a poke |
105 | unsigned int i; | 105 | unsigned int i; |
106 | for (i=1;i<m_iChars;i++) { | 106 | for (i=1;i<m_iChars;i++) { |
107 | m_Children[i]->m_iAge=0; | 107 | m_Children[i]->m_iAge=0; |
108 | m_Children[i]->m_bAlive=1; | 108 | m_Children[i]->m_bAlive=1; |
109 | } | 109 | } |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | 112 | ||
113 | // if we haven't got a context then try to get a new one | 113 | // if we haven't got a context then try to get a new one |
114 | if (m_parent) | 114 | if (m_parent) |
115 | m_context=m_languagemodel->CloneNodeContext(m_parent->m_context); | 115 | m_context=m_languagemodel->CloneNodeContext(m_parent->m_context); |
116 | else | 116 | else |
117 | m_context=m_languagemodel->GetRootNodeContext(); | 117 | m_context=m_languagemodel->GetRootNodeContext(); |
118 | 118 | ||
119 | // if it fails, be patient | 119 | // if it fails, be patient |
120 | if (!m_context) | 120 | if (!m_context) |
121 | return; | 121 | return; |
122 | Generic_Push_Node(m_context); | 122 | Generic_Push_Node(m_context); |
123 | } | 123 | } |
124 | 124 | ||
125 | ///////////////////////////////////////////////////////////////////////////// | 125 | ///////////////////////////////////////////////////////////////////////////// |
126 | 126 | ||
127 | void CDasherNode::Get_string_under(const int iNormalization,const myint miY1,const myint miY2,const myint miMousex,const myint miMousey, vector<symbol> &vString) const | 127 | void CDasherNode::Get_string_under(const int iNormalization,const myint miY1,const myint miY2,const myint miMousex,const myint miMousey, vector<symbol> &vString) const |
128 | { | 128 | { |
129 | // we are over (*this) node so add it to the string | 129 | // we are over (*this) node so add it to the string |
130 | vString.push_back(m_Symbol); | 130 | vString.push_back(m_Symbol); |
131 | 131 | ||