[dasher] Rename UpdatePosition to OneStepTowards.



commit 1f3c225ea110f099f39d1ddaf488e469b3cd99b2
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Mon May 18 14:35:25 2009 +0100

    Rename UpdatePosition to OneStepTowards.
    
    Pausedness seems a property of the input filter, rather than of
    OneStepTowards; starting to make it so, moving/combining many checks on
    it into DefaultFilter.
---
 ChangeLog                                 |    5 +++
 Src/DasherCore/AutoSpeedControl.cpp       |    2 +-
 Src/DasherCore/DasherModel.cpp            |    4 +-
 Src/DasherCore/DasherModel.h              |    6 ++--
 Src/DasherCore/DefaultFilter.cpp          |   47 ++++++++++++++++-------------
 Src/DasherCore/DynamicFilter.cpp          |    4 +-
 Src/DasherCore/EyetrackerFilter.cpp       |    3 --
 Src/DasherCore/OneButtonDynamicFilter.cpp |    2 +-
 Src/DasherCore/TwoButtonDynamicFilter.cpp |    2 +-
 9 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f279765..1ff7551 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-05-18  Alan Lawrence <acl33 inf phy cam ac uk>
 
+	* Rename UpdatePosition to OneStepTowards.
+	* Reorganize checks on BP_DASHER_PAUSED.
+
+2009-05-18  Alan Lawrence <acl33 inf phy cam ac uk>
+
 	* ClickFilter.cpp, DasherButtons.cpp, DasherModel.{h,cpp}:
 	Split UpdatePosition into NextScheduledStep and UpdatePosition, with
 	common code in UpdateBounds.
diff --git a/Src/DasherCore/AutoSpeedControl.cpp b/Src/DasherCore/AutoSpeedControl.cpp
index b8813e9..44bd022 100644
--- a/Src/DasherCore/AutoSpeedControl.cpp
+++ b/Src/DasherCore/AutoSpeedControl.cpp
@@ -179,7 +179,7 @@ inline void CAutoSpeedControl::UpdateSigmas(double r, double dFrameRate)
 
 
 void CAutoSpeedControl::SpeedControl(myint iDasherX, myint iDasherY, double dFrameRate, CDasherView *pView) {
-  if(GetBoolParameter(BP_AUTO_SPEEDCONTROL) && !GetBoolParameter(BP_DASHER_PAUSED)) {
+  if(GetBoolParameter(BP_AUTO_SPEEDCONTROL)) {
     
 //  Coordinate transforms:
 	double r,theta;
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index e8d3e90..3142244 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -479,8 +479,8 @@ bool CDasherModel::NextScheduledStep(unsigned long iTime, Dasher::VECTOR_SYMBOL_
   return UpdateBounds(iNewMin, iNewMax, iTime, pAdded, pNumDeleted);
 }
 
-bool CDasherModel::UpdatePosition(myint miMousex, myint miMousey, unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB* pAdded, int* pNumDeleted) {
-  if (GetBoolParameter(BP_DASHER_PAUSED)) return false;
+bool CDasherModel::OneStepTowards(myint miMousex, myint miMousey, unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB* pAdded, int* pNumDeleted) {
+  //if (GetBoolParameter(BP_DASHER_PAUSED)) return false;
   DASHER_ASSERT(m_deGotoQueue.size() == 0);
 
   myint iNewMin, iNewMax;
diff --git a/Src/DasherCore/DasherModel.h b/Src/DasherCore/DasherModel.h
index 2f5e0a6..f4573de 100644
--- a/Src/DasherCore/DasherModel.h
+++ b/Src/DasherCore/DasherModel.h
@@ -75,7 +75,7 @@ class Dasher::CDasherModel:public Dasher::CDasherComponent, private NoClones
   ///
   /// Update the root location with *one step* towards the specified
   /// co-ordinates - used by timer callbacks (for non-button modes)
-  bool UpdatePosition(myint, myint, unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB* pAdded = NULL, int* pNumDeleted = NULL);  
+  bool OneStepTowards(myint, myint, unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB* pAdded = NULL, int* pNumDeleted = NULL);  
 
   ///
   /// Notify the framerate class that a new frame has occurred
@@ -215,7 +215,7 @@ class Dasher::CDasherModel:public Dasher::CDasherComponent, private NoClones
   ///
   /// Check whether a change of root node is needed, and perform the
   /// update if so
-  /// TODO: Could be done in UpdatePosition?
+  /// TODO: Could be done in UpdateBounds?
   ///
 
   bool CheckForNewRoot(CDasherView *pView);
@@ -241,7 +241,7 @@ class Dasher::CDasherModel:public Dasher::CDasherComponent, private NoClones
 
  private:
 
-  /// Common portion of UpdatePosition / NextScheduledStep, taking
+  /// Common portion of OneStepTowards / NextScheduledStep, taking
   /// bounds for the root node in the next frame.
   bool UpdateBounds(myint iNewMin, myint iNewMax, unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted);
 
diff --git a/Src/DasherCore/DefaultFilter.cpp b/Src/DasherCore/DefaultFilter.cpp
index aac3e2b..8e6620c 100644
--- a/Src/DasherCore/DefaultFilter.cpp
+++ b/Src/DasherCore/DefaultFilter.cpp
@@ -41,30 +41,35 @@ bool CDefaultFilter::DecorateView(CDasherView *pView) {
 }
 
 bool CDefaultFilter::Timer(int Time, CDasherView *m_pDasherView, CDasherModel *m_pDasherModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted) {
-  myint iDasherX;
-  myint iDasherY;
-
-  m_pDasherView->GetCoordinates(iDasherX, iDasherY);
-
-  ApplyAutoCalibration(iDasherX, iDasherY, true);
-  ApplyTransform(iDasherX, iDasherY);
-
-  if(GetBoolParameter(BP_PAUSE_OUTSIDE) && !GetBoolParameter(BP_DASHER_PAUSED)) {
-    myint iDasherMinX;
-    myint iDasherMinY;
-    myint iDasherMaxX;
-    myint iDasherMaxY;
-    m_pDasherView->VisibleRegion(iDasherMinX, iDasherMinY, iDasherMaxX, iDasherMaxY);
-  
-    if((iDasherX > iDasherMaxX) || (iDasherX < iDasherMinX) || (iDasherY > iDasherMaxY) || (iDasherY < iDasherMinY))
-      m_pInterface->PauseAt(0,0);
-  }
-
   bool bDidSomething;
-  bDidSomething = m_pDasherModel->UpdatePosition(iDasherX,iDasherY, Time, pAdded, pNumDeleted);
+  if (!GetBoolParameter(BP_DASHER_PAUSED))
+  {
+    myint iDasherX;
+    myint iDasherY;
+
+    m_pDasherView->GetCoordinates(iDasherX, iDasherY);
+
+    ApplyAutoCalibration(iDasherX, iDasherY, true);
+    ApplyTransform(iDasherX, iDasherY);
+
+    if(GetBoolParameter(BP_PAUSE_OUTSIDE)) {
+      myint iDasherMinX;
+      myint iDasherMinY;
+      myint iDasherMaxX;
+      myint iDasherMaxY;
+      m_pDasherView->VisibleRegion(iDasherMinX, iDasherMinY, iDasherMaxX, iDasherMaxY);
+  
+      if((iDasherX > iDasherMaxX) || (iDasherX < iDasherMinX) || (iDasherY > iDasherMaxY) || (iDasherY < iDasherMinY))
+        m_pInterface->PauseAt(0,0);
+		return false;
+    }
 
-  m_pAutoSpeedControl->SpeedControl(iDasherX, iDasherY, m_pDasherModel->Framerate(), m_pDasherView);
+    bDidSomething = m_pDasherModel->OneStepTowards(iDasherX,iDasherY, Time, pAdded, pNumDeleted);
+	DASHER_ASSERT (bDidSomething);
 
+    m_pAutoSpeedControl->SpeedControl(iDasherX, iDasherY, m_pDasherModel->Framerate(), m_pDasherView);
+  }
+	
   if(m_pStartHandler)
     m_pStartHandler->Timer(Time, m_pDasherView, m_pDasherModel);
 
diff --git a/Src/DasherCore/DynamicFilter.cpp b/Src/DasherCore/DynamicFilter.cpp
index e22291f..9f207af 100644
--- a/Src/DasherCore/DynamicFilter.cpp
+++ b/Src/DasherCore/DynamicFilter.cpp
@@ -35,8 +35,8 @@ bool CDynamicFilter::Timer(int Time, CDasherView *m_pDasherView, CDasherModel *m
     return true;
   }
 
-  if(m_iState == 2)
-    return m_pDasherModel->UpdatePosition(41943,2048, Time, pAdded, pNumDeleted);
+  if(m_iState == 2) //backing off
+    return m_pDasherModel->OneStepTowards(41943,2048, Time, pAdded, pNumDeleted);
   else if(m_iState == 1)
     return TimerImpl(Time, m_pDasherView, m_pDasherModel, pAdded, pNumDeleted);
   else
diff --git a/Src/DasherCore/EyetrackerFilter.cpp b/Src/DasherCore/EyetrackerFilter.cpp
index a3b2e0f..a53df89 100644
--- a/Src/DasherCore/EyetrackerFilter.cpp
+++ b/Src/DasherCore/EyetrackerFilter.cpp
@@ -92,9 +92,6 @@ void CEyetrackerFilter::ApplyAutoCalibration(myint &iDasherX, myint &iDasherY, b
 
   iDasherY += 10 * m_iYAutoOffset;
 
-  if(GetBoolParameter(BP_DASHER_PAUSED))
-    return;
-
   if(!bUpdate)
     return;
 
diff --git a/Src/DasherCore/OneButtonDynamicFilter.cpp b/Src/DasherCore/OneButtonDynamicFilter.cpp
index 07c1d4a..585cfc5 100644
--- a/Src/DasherCore/OneButtonDynamicFilter.cpp
+++ b/Src/DasherCore/OneButtonDynamicFilter.cpp
@@ -93,7 +93,7 @@ bool COneButtonDynamicFilter::DecorateView(CDasherView *pView) {
 }
 
 bool COneButtonDynamicFilter::TimerImpl(int Time, CDasherView *m_pDasherView, CDasherModel *m_pDasherModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted) {
-  return m_pDasherModel->UpdatePosition(m_iTargetX[m_iTarget], m_iTargetY[m_iTarget], Time, pAdded, pNumDeleted);
+  return m_pDasherModel->OneStepTowards(m_iTargetX[m_iTarget], m_iTargetY[m_iTarget], Time, pAdded, pNumDeleted);
 }
 
 void COneButtonDynamicFilter::ActionButton(int iTime, int iButton, int iType, CDasherModel *pModel, CUserLogBase *pUserLog) {
diff --git a/Src/DasherCore/TwoButtonDynamicFilter.cpp b/Src/DasherCore/TwoButtonDynamicFilter.cpp
index eb6453d..343167e 100644
--- a/Src/DasherCore/TwoButtonDynamicFilter.cpp
+++ b/Src/DasherCore/TwoButtonDynamicFilter.cpp
@@ -96,7 +96,7 @@ bool CTwoButtonDynamicFilter::DecorateView(CDasherView *pView) {
 }
 
 bool CTwoButtonDynamicFilter::TimerImpl(int Time, CDasherView *m_pDasherView, CDasherModel *m_pDasherModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted) {
-  return m_pDasherModel->UpdatePosition(100,2048, Time, pAdded, pNumDeleted);
+  return m_pDasherModel->OneStepTowards(100,2048, Time, pAdded, pNumDeleted);
 }
 
 void CTwoButtonDynamicFilter::Activate() {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]