[dasher] Cleanup: removed NF_SUBNODE flag, as nodes with it are no more! :-)
- From: Patrick Welche <pwelche src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dasher] Cleanup: removed NF_SUBNODE flag, as nodes with it are no more! :-)
- Date: Sat, 19 Dec 2009 22:19:59 +0000 (UTC)
commit 62ee0d542f1d5f98546c22a7f7ce413210300493
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Wed Dec 2 21:38:18 2009 +0000
Cleanup: removed NF_SUBNODE flag, as nodes with it are no more! :-)
Also DasherModel::RecursiveCheckRoot (as no longer needs to recurse!)
Src/DasherCore/AlphabetManager.cpp | 2 -
Src/DasherCore/DasherModel.cpp | 85 ++++++++++-------------------------
Src/DasherCore/DasherModel.h | 2 -
Src/DasherCore/DasherNode.cpp | 4 --
Src/DasherCore/DasherNode.h | 12 ++---
Src/DasherCore/DasherViewSquare.cpp | 6 +-
6 files changed, 31 insertions(+), 80 deletions(-)
---
diff --git a/Src/DasherCore/AlphabetManager.cpp b/Src/DasherCore/AlphabetManager.cpp
index 915ef8a..fc347b9 100644
--- a/Src/DasherCore/AlphabetManager.cpp
+++ b/Src/DasherCore/AlphabetManager.cpp
@@ -225,8 +225,6 @@ CAlphabetManager::CGroupNode *CAlphabetManager::CreateGroupNode(CAlphNode *pPare
CGroupNode *pNewNode = makeGroup(pParent, iLbnd, iHbnd, pDisplayInfo, pInfo);
- //pNewNode->SetFlag(NF_SUBNODE, true);
-
// When creating a group node...
pNewNode->m_iOffset = pParent->m_iOffset; // ...the offset is the same as the parent...
pNewNode->iContext = m_pLanguageModel->CloneContext(pParent->iContext);
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index d9ecc13..50e6e48 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -147,9 +147,6 @@ void CDasherModel::HandleEvent(Dasher::CEvent *pEvent) {
}
void CDasherModel::Make_root(CDasherNode *pNewRoot) {
- // TODO: Note that subnodes can be the root transiently during the
- // re-rooting process.
-
// std::cout << "Make root" << std::endl;
DASHER_ASSERT(pNewRoot != NULL);
@@ -162,8 +159,7 @@ void CDasherModel::Make_root(CDasherNode *pNewRoot) {
oldroots.push_back(m_Root);
// TODO: tidy up conditional
- while(((oldroots.size() > 10) && (!m_bRequireConversion || (oldroots[0]->GetFlag(NF_CONVERTED)))) ||
- (oldroots[0]->GetFlag(NF_SUBNODE))) {
+ while((oldroots.size() > 10) && (!m_bRequireConversion || (oldroots[0]->GetFlag(NF_CONVERTED)))) {
oldroots[0]->OrphanChild(oldroots[1]);
delete oldroots[0];
oldroots.pop_front();
@@ -204,9 +200,6 @@ void CDasherModel::RecursiveMakeRoot(CDasherNode *pNewRoot) {
void CDasherModel::RebuildAroundNode(CDasherNode *pNode) {
DASHER_ASSERT(pNode != NULL);
- while(pNode->GetFlag(NF_SUBNODE))
- pNode = pNode->Parent();
-
RecursiveMakeRoot(pNode);
ClearRootQueue();
@@ -231,19 +224,12 @@ void CDasherModel::Reparent_root(int lower, int upper) {
else {
pNewRoot = oldroots.back();
oldroots.pop_back();
-
- while((oldroots.size() > 0) && pNewRoot->GetFlag(NF_SUBNODE)) {
- pNewRoot = oldroots.back();
- oldroots.pop_back();
- }
}
// Return if there's no existing parent and no way of recreating one
if(pNewRoot == NULL)
return;
- DASHER_ASSERT(!(pNewRoot->GetFlag(NF_SUBNODE)));
-
pNewRoot->SetFlag(NF_COMMITTED, false);
CDasherNode *pCurrent = m_Root;
@@ -260,11 +246,10 @@ void CDasherModel::Reparent_root(int lower, int upper) {
myint iRootWidth = m_Rootmax - m_Rootmin;
// Fail and undo root creation if the new root is bigger than allowed by normalisation
- if(!(pNewRoot->GetFlag(NF_SUBNODE)) &&
- (((myint((GetLongParameter(LP_NORMALIZATION) - upper)) / static_cast<double>(iWidth)) >
+ if(((myint((GetLongParameter(LP_NORMALIZATION) - upper)) / static_cast<double>(iWidth)) >
(m_Rootmax_max - m_Rootmax)/static_cast<double>(iRootWidth)) ||
((myint(lower) / static_cast<double>(iWidth)) >
- (m_Rootmin - m_Rootmin_min) / static_cast<double>(iRootWidth)))) {
+ (m_Rootmin - m_Rootmin_min) / static_cast<double>(iRootWidth))) {
pNewRoot->OrphanChild(m_Root);
delete pNewRoot;
return;
@@ -648,12 +633,8 @@ bool CDasherModel::DeleteCharacters(CDasherNode *newnode, CDasherNode *oldnode,
void CDasherModel::Push_Node(CDasherNode *pNode) {
DASHER_ASSERT(pNode != NULL);
- // TODO: Fix this and make an assertion again
- if(pNode->GetFlag(NF_SUBNODE))
- return;
// TODO: Is NF_ALLCHILDREN any more useful/efficient than reading the map size?
-
if(pNode->GetFlag(NF_ALLCHILDREN)) {
DASHER_ASSERT(pNode->GetChildren().size() > 0);
@@ -663,8 +644,15 @@ void CDasherModel::Push_Node(CDasherNode *pNode) {
// TODO: Do we really need to delete all of the children at this point?
pNode->Delete_children(); // trial commented out - pconlon
- // Populate children creates two levels at once - the groups and their children.
+#ifdef DEBUG
+ unsigned int iExpect = pNode->ExpectedNumChildren();
+#endif
pNode->PopulateChildren();
+#ifdef DEBUG
+ if (iExpect != pNode->GetChildren().size()) {
+ std::cout << "(Note: expected " << iExpect << " children, actually created " << pNode->GetChildren().size() << ")" << std::endl;
+ }
+#endif
pNode->SetFlag(NF_ALLCHILDREN, true);
@@ -760,31 +748,6 @@ bool CDasherModel::RenderToView(CDasherView *pView, NodeQueue &nodeQueue) {
return bReturnValue;
}
-// Return true to indicate zero or one nodes found, false for more than one
-bool CDasherModel::RecursiveCheckRoot(CDasherNode *pNode, CDasherNode **pNewNode, bool &bFound) {
- DASHER_ASSERT(pNode != NULL);
- DASHER_ASSERT(pNewNode != NULL);
-
- const CDasherNode::ChildMap & children = pNode->GetChildren();
-
- for(CDasherNode::ChildMap::const_iterator it(children.begin()); it != children.end(); ++it) {
- if((*it)->GetFlag(NF_SUBNODE)) {
- if(!RecursiveCheckRoot(*it, pNewNode, bFound))
- return false;
- }
- else if((*it)->GetFlag(NF_SUPER)) {
- if(bFound) // TODO: This should be an error (and probably isn't worth checking for)
- return false;
- else {
- *pNewNode = *it;
- bFound = true;
- }
- }
- }
-
- return true;
-}
-
bool CDasherModel::CheckForNewRoot(CDasherView *pView) {
DASHER_ASSERT(m_Root != NULL);
// TODO: pView is redundant here
@@ -795,25 +758,26 @@ bool CDasherModel::CheckForNewRoot(CDasherView *pView) {
if(!(m_Root->GetFlag(NF_SUPER))) {
Reparent_root(root->Lbnd(), root->Hbnd());
- DASHER_ASSERT(!(m_Root->GetFlag(NF_SUBNODE)));
return(m_Root != root);
}
- DASHER_ASSERT(!(m_Root->GetFlag(NF_SUBNODE)));
-
CDasherNode *pNewRoot = NULL;
- bool bFound = false;
-
- if(RecursiveCheckRoot(m_Root, &pNewRoot, bFound)) {
- // TODO: I think this if statement is reduncdent, return value of above is always equal to bFound
- // not true - pconlon
- ////GAME MODE TEMP - only change the root if it is on the game path/////////
- if(bFound && (!m_bGameMode || pNewRoot->GetFlag(NF_GAME))) {
- m_Root->DeleteNephews(pNewRoot);
- RecursiveMakeRoot(pNewRoot);
+ for (CDasherNode::ChildMap::const_iterator it = m_Root->GetChildren().begin(); it != m_Root->GetChildren().end(); it++) {
+ if ((*it)->GetFlag(NF_SUPER)) {
+ //at most one child should have NF_SUPER set...
+ DASHER_ASSERT(pNewRoot == NULL);
+ pNewRoot = *it;
+#ifndef DEBUG
+ break;
+#endif
}
}
+ ////GAME MODE TEMP - only change the root if it is on the game path/////////
+ if (pNewRoot && (!m_bGameMode || pNewRoot->GetFlag(NF_GAME))) {
+ m_Root->DeleteNephews(pNewRoot);
+ RecursiveMakeRoot(pNewRoot);
+ }
CDasherNode *pNewNode = Get_node_under_crosshair();
@@ -822,7 +786,6 @@ bool CDasherModel::CheckForNewRoot(CDasherView *pView) {
if(pNewNode != pOldNode)
HandleOutput(pNewNode, pOldNode, NULL, NULL);
- DASHER_ASSERT(!(m_Root->GetFlag(NF_SUBNODE)));
return false;
}
diff --git a/Src/DasherCore/DasherModel.h b/Src/DasherCore/DasherModel.h
index e6eb66c..b2006be 100644
--- a/Src/DasherCore/DasherModel.h
+++ b/Src/DasherCore/DasherModel.h
@@ -367,8 +367,6 @@ class Dasher::CDasherModel:public CFrameRate, private NoClones
void HandleOutput(CDasherNode *pNewNode, CDasherNode *pOldNode, Dasher::VECTOR_SYMBOL_PROB* pAdded, int* pNumDeleted);
- bool RecursiveCheckRoot(CDasherNode *pNode, CDasherNode **pNewNode, bool &bFound);
-
///
/// Clear the queue of old roots - used when those nodes become
diff --git a/Src/DasherCore/DasherNode.cpp b/Src/DasherCore/DasherNode.cpp
index 07d85c2..0a3d220 100644
--- a/Src/DasherCore/DasherNode.cpp
+++ b/Src/DasherCore/DasherNode.cpp
@@ -158,12 +158,8 @@ void CDasherNode::DeleteNephews(CDasherNode *pChild) {
ChildMap::iterator i;
for(i = Children().begin(); i != Children().end(); i++) {
- if((*i)->GetFlag(NF_SUBNODE))
- (*i)->DeleteNephews(pChild);
- else {
if(*i != pChild) {
(*i)->Delete_children();
- }
}
}
}
diff --git a/Src/DasherCore/DasherNode.h b/Src/DasherCore/DasherNode.h
index ce8215c..b537589 100644
--- a/Src/DasherCore/DasherNode.h
+++ b/Src/DasherCore/DasherNode.h
@@ -39,9 +39,8 @@ namespace Dasher {
#define NF_CONVERTED 4
#define NF_GAME 8
#define NF_ALLCHILDREN 16
-#define NF_SUBNODE 32
-#define NF_SUPER 64
-#define NF_END_GAME 128
+#define NF_SUPER 32
+#define NF_END_GAME 64
/// \ingroup Model
/// @{
@@ -110,8 +109,6 @@ class Dasher::CDasherNode:private NoClones {
///
/// NF_ALLCHILDREN - Node has all children (TODO: obsolete?)
///
- /// NF_SUBNODE - Node should be considered an integral subnode of parents (eg groups)
- ///
/// NF_SUPER - Node covers entire visible area
///
/// NF_END_GAME - Node is the last one of the phrase in game mode
@@ -216,7 +213,7 @@ class Dasher::CDasherNode:private NoClones {
///
/// Sees if a *child* / descendant of the specified node (not that node itself)
/// represents the specified character. If so, set the child & intervening nodes'
- /// NF_SUBNODE flag, and return true; otherwise, return false.
+ /// NF_GAME flag, and return true; otherwise, return false.
///
bool GameSearchChildren(std::string strTargetUtf8Char);
@@ -258,8 +255,7 @@ class Dasher::CDasherNode:private NoClones {
virtual void SetControlOffset(int iOffset) {};
///
- /// See if this node, or *if an NF_SUBNODE* a descendant (recursively),
- /// represents the specified alphanumeric character; if so, set it's NF_GAME flag and
+ /// See if this node represents the specified alphanumeric character; if so, set it's NF_GAME flag and
/// return true; otherwise, return false.
///
virtual bool GameSearchNode(std::string strTargetUtf8Char) {return false;}
diff --git a/Src/DasherCore/DasherViewSquare.cpp b/Src/DasherCore/DasherViewSquare.cpp
index bb4d640..a5d4e87 100644
--- a/Src/DasherCore/DasherViewSquare.cpp
+++ b/Src/DasherCore/DasherViewSquare.cpp
@@ -225,7 +225,7 @@ bool CDasherViewSquare::CheckRender(CDasherNode *pRender, myint y1, myint y2,
//
// TODO: Should probably render the parent segment here anyway (or
// in the above)
- if(!pRender->GetFlag(NF_GAME) && !pRender->GetFlag(NF_SUBNODE))
+ if(!pRender->GetFlag(NF_GAME))
pRender->Delete_children();
return false;
}
@@ -295,7 +295,7 @@ void CDasherViewSquare::RecursiveRender(CDasherNode *pRender, myint y1, myint y2
}
//Node has children. It can therefore be collapsed...
- if (!pRender->GetFlag(NF_GAME) && !pRender->GetFlag(NF_SUBNODE)
+ if (!pRender->GetFlag(NF_GAME)
&& pRender->m_dCost!=std::numeric_limits<double>::infinity()) //don't collapse a node covering the screen!!
nodeQueue.pushNodeToCollapse(pRender);
@@ -380,7 +380,7 @@ void CDasherViewSquare::RecursiveRender(CDasherNode *pRender, myint y1, myint y2
}
}
// Draw the outline
- if(pRender->GetDisplayInfo()->bVisible && !(pRender->GetFlag(NF_SUBNODE))) {
+ if(pRender->GetDisplayInfo()->bVisible) {
RenderNodeOutlineFast(pRender->GetDisplayInfo()->iColour,
y1, y2, mostleft,
pRender->GetDisplayInfo()->strDisplayText,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]