[dasher] For input filters using ScheduleZoom, the co-ordinates they passed to
- From: Patrick Welche <pwelche src gnome org>
- To: svn-commits-list gnome org
- Subject: [dasher] For input filters using ScheduleZoom, the co-ordinates they passed to
- Date: Mon, 18 May 2009 09:40:08 -0400 (EDT)
commit ce42457a8ae38b9dd223b8dbe9e13c7388622653
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Mon May 18 14:21:09 2009 +0100
For input filters using ScheduleZoom, the co-ordinates they passed to
UpdatePosition were ignored. This mode of operation has been separated
out, so that such filters should now call NextScheduledStep instead.
---
ChangeLog | 6 ++++
Src/DasherCore/ClickFilter.cpp | 2 +-
Src/DasherCore/DasherButtons.cpp | 2 +-
Src/DasherCore/DasherInterfaceBase.cpp | 4 ++-
Src/DasherCore/DasherModel.cpp | 46 ++++++++++++++++----------------
Src/DasherCore/DasherModel.h | 20 +++++++-------
6 files changed, 44 insertions(+), 36 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9cbe697..821bb24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
2009-05-16 Patrick Welche <prlw1 cam ac uk>
* Makefile.am, configure.ac: Don't delete gnome-doc-utils.make
diff --git a/Src/DasherCore/ClickFilter.cpp b/Src/DasherCore/ClickFilter.cpp
index 6daa403..289be35 100644
--- a/Src/DasherCore/ClickFilter.cpp
+++ b/Src/DasherCore/ClickFilter.cpp
@@ -12,7 +12,7 @@ bool CClickFilter::DecorateView(CDasherView *pView) {
}
bool CClickFilter::Timer(int Time, CDasherView *pDasherView, CDasherModel *pModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted) {
- return pModel->UpdatePosition(0, 0, Time, pAdded, pNumDeleted);
+ return pModel->NextScheduledStep(Time, pAdded, pNumDeleted);
}
void CClickFilter::KeyDown(int iTime, int iId, CDasherView *pDasherView, CDasherModel *pModel, CUserLogBase *pUserLog, bool bPos, int iX, int iY) {
diff --git a/Src/DasherCore/DasherButtons.cpp b/Src/DasherCore/DasherButtons.cpp
index 733c423..22c9988 100644
--- a/Src/DasherCore/DasherButtons.cpp
+++ b/Src/DasherCore/DasherButtons.cpp
@@ -418,7 +418,7 @@ bool CDasherButtons::Timer(int Time, CDasherView *m_pDasherView, CDasherModel *m
m_pDasherView->GetCoordinates(iDasherX, iDasherY);
// ----
- return m_pDasherModel->UpdatePosition(0, 0, Time, pAdded, pNumDeleted);
+ return m_pDasherModel->NextScheduledStep(Time, pAdded, pNumDeleted);
}
void CDasherButtons::HandleEvent(Dasher::CEvent * pEvent) {
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 20a9c4e..51a7a2d 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -537,7 +537,9 @@ void CDasherInterfaceBase::NewFrame(unsigned long iTime, bool bForceRedraw) {
if(m_pDasherView != 0) {
if(!GetBoolParameter(BP_TRAINING)) {
if (m_pUserLog != NULL) {
-
+ //ACL note that as of 15/5/09, splitting UpdatePosition into two,
+ //DasherModel no longer guarantees to empty these two if it didn't do anything.
+ //So initialise appropriately...
Dasher::VECTOR_SYMBOL_PROB vAdded;
int iNumDeleted = 0;
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index f8cce6d..e8d3e90 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -467,35 +467,35 @@ void CDasherModel::Get_new_root_coords(dasherint X, dasherint Y, dasherint &r1,
r2 = ((R2 - C) * Y2) / (y2 - y1) + C;
}
-bool CDasherModel::UpdatePosition(myint miMousex, myint miMousey, unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB* pAdded, int* pNumDeleted) {
- // Clear out parameters that might get passed in to track user activity
- if (pAdded != NULL)
- pAdded->clear();
- if (pNumDeleted != NULL)
- *pNumDeleted = 0;
-
- if(GetBoolParameter(BP_DASHER_PAUSED) && (m_deGotoQueue.size() == 0))
- return false;
-
- // Find out the current node under the crosshair
- CDasherNode *old_under_cross=Get_node_under_crosshair();
-
+bool CDasherModel::NextScheduledStep(unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted)
+{
+ DASHER_ASSERT(GetBoolParameter(BP_DASHER_PAUSED));
+ if (m_deGotoQueue.size() == 0) return false;
+ myint iNewMin, iNewMax;
+ iNewMin = m_deGotoQueue.front().iN1;
+ iNewMax = m_deGotoQueue.front().iN2;
+ m_deGotoQueue.pop_front();
+
+ return UpdateBounds(iNewMin, iNewMax, iTime, pAdded, pNumDeleted);
+}
- myint iNewMin;
- myint iNewMax;
+bool CDasherModel::UpdatePosition(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);
- if(m_deGotoQueue.size() == 0) {
- // works out next viewpoint
+ myint iNewMin, iNewMax;
+ // works out next viewpoint
Get_new_root_coords(miMousex, miMousey, iNewMin, iNewMax, iTime);
if(GetBoolParameter(BP_OLD_STYLE_PUSH))
OldPush(miMousex, miMousey);
- }
- else {
- iNewMin = m_deGotoQueue.front().iN1;
- iNewMax = m_deGotoQueue.front().iN2;
- m_deGotoQueue.pop_front();
- }
+
+ UpdateBounds(iNewMin, iNewMax, iTime, pAdded, pNumDeleted);
+}
+
+bool CDasherModel::UpdateBounds(myint iNewMin, myint iNewMax, unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB* pAdded, int* pNumDeleted) {
+ // Find out the current node under the crosshair
+ CDasherNode *old_under_cross=Get_node_under_crosshair();
m_dTotalNats += log((iNewMax - iNewMin) / static_cast<double>(m_Rootmax - m_Rootmin));
diff --git a/Src/DasherCore/DasherModel.h b/Src/DasherCore/DasherModel.h
index fef7514..2f5e0a6 100644
--- a/Src/DasherCore/DasherModel.h
+++ b/Src/DasherCore/DasherModel.h
@@ -73,11 +73,8 @@ class Dasher::CDasherModel:public Dasher::CDasherComponent, private NoClones
/// @{
///
- /// Update the root location - called in response to regular timer
- /// callbacks, mainly from the timer events of various button
- /// handlers
- /// TODO: Make this a bit more central in the button handler hierarchy
- ///
+ /// 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);
///
@@ -181,12 +178,11 @@ class Dasher::CDasherModel:public Dasher::CDasherComponent, private NoClones
void ScheduleZoom(dasherint iDasherX, dasherint iDasherY, int iMaxZoom = 0);
///
- /// Return the number of remaining zoom steps
+ /// Update the bounds of the root node for the next step in any
+ /// still-in-progress zoom scheduled by ScheduleZoom (does nothing
+ /// if no steps remaining / no zoom scheduled).
///
-
- int ScheduledSteps() {
- return m_deGotoQueue.size();
- }
+ bool NextScheduledStep(unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB* pAdded = NULL, int *pNumDeleted = NULL);
/// @}
@@ -245,6 +241,10 @@ class Dasher::CDasherModel:public Dasher::CDasherComponent, private NoClones
private:
+ /// Common portion of UpdatePosition / 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);
+
/// Struct representing intermediate stages in the goto queue
///
struct SGotoItem {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]