[dasher: 32/38] Refactor: make nSteps a parameter to ScheduleZoom; simplify ZoomAdjuster intf
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 32/38] Refactor: make nSteps a parameter to ScheduleZoom; simplify ZoomAdjuster intf
- Date: Tue, 3 Jan 2012 15:35:22 +0000 (UTC)
commit 2840604adeee130502f71cc20d2be3efd2a2f27c
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Tue Nov 22 18:40:07 2011 +0000
Refactor: make nSteps a parameter to ScheduleZoom; simplify ZoomAdjuster intf
DasherModel makes no use of user prefs, does not need to inherit SettingsUser
Src/DasherCore/ClickFilter.h | 4 ++--
Src/DasherCore/DasherButtons.cpp | 2 +-
Src/DasherCore/DasherButtons.h | 2 +-
Src/DasherCore/DasherInterfaceBase.cpp | 2 +-
Src/DasherCore/DasherModel.cpp | 6 ++----
Src/DasherCore/DasherModel.h | 28 ++++++++++++----------------
Src/DasherCore/DynamicFilter.cpp | 4 ++--
Src/DasherCore/DynamicFilter.h | 2 +-
Src/DasherCore/InputFilter.h | 13 +++++++------
Src/DasherCore/OneButtonFilter.cpp | 2 +-
Src/DasherCore/OneButtonFilter.h | 2 +-
Src/DasherCore/StylusFilter.cpp | 2 +-
12 files changed, 32 insertions(+), 37 deletions(-)
---
diff --git a/Src/DasherCore/ClickFilter.h b/Src/DasherCore/ClickFilter.h
index 76b86cf..f8bce1f 100644
--- a/Src/DasherCore/ClickFilter.h
+++ b/Src/DasherCore/ClickFilter.h
@@ -17,10 +17,10 @@ namespace Dasher {
void AdjustZoomX(myint &iDasherX, CDasherView *comp, myint safety, myint maxZoom);
};
-class CClickFilter : public CStaticFilter, protected CSettingsUser, private CZoomAdjuster {
+class CClickFilter : public CStaticFilter, private CZoomAdjuster {
public:
CClickFilter(CSettingsUser *pCreator, CDasherInterfaceBase *pInterface)
- : CStaticFilter(pInterface, 7, _("Click Mode")), CSettingsUser(pCreator) { };
+ : CStaticFilter(pCreator, pInterface, 7, _("Click Mode")) { };
virtual bool DecorateView(CDasherView *pView, CDasherInput *pInput);
virtual void KeyDown(unsigned long iTime, int iId, CDasherView *pView, CDasherInput *pInput, CDasherModel *pModel);
diff --git a/Src/DasherCore/DasherButtons.cpp b/Src/DasherCore/DasherButtons.cpp
index c04adb1..447994c 100644
--- a/Src/DasherCore/DasherButtons.cpp
+++ b/Src/DasherCore/DasherButtons.cpp
@@ -24,7 +24,7 @@ static char THIS_FILE[] = __FILE__;
using namespace Dasher;
CDasherButtons::CDasherButtons(CSettingsUser *pCreator, CDasherInterfaceBase *pInterface, bool bMenu, ModuleID_t iID, const char *szName)
- : CStaticFilter(pInterface, iID, szName), CSettingsUser(pCreator), m_bMenu(bMenu), m_bDecorationChanged(true), m_pBoxes(NULL), iActiveBox(0) {}
+ : CStaticFilter(pCreator, pInterface, iID, szName), m_bMenu(bMenu), m_bDecorationChanged(true), m_pBoxes(NULL), iActiveBox(0) {}
CDasherButtons::~CDasherButtons()
{
diff --git a/Src/DasherCore/DasherButtons.h b/Src/DasherCore/DasherButtons.h
index 0adb5af..f1bf0a1 100644
--- a/Src/DasherCore/DasherButtons.h
+++ b/Src/DasherCore/DasherButtons.h
@@ -18,7 +18,7 @@ using namespace std;
namespace Dasher {
/// \ingroup Input
/// @{
-class CDasherButtons : public CStaticFilter, protected CSettingsUser
+class CDasherButtons : public CStaticFilter
{
public:
CDasherButtons(CSettingsUser *pCreator, CDasherInterfaceBase *pInterface, bool bMenu, ModuleID_t iID, const char *szName);
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 9cadc4e..12653f5 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -85,7 +85,7 @@ static char THIS_FILE[] = __FILE__;
#endif
#endif
-CDasherInterfaceBase::CDasherInterfaceBase(CSettingsStore *pSettingsStore) : CSettingsUser(pSettingsStore), m_pSettingsStore(pSettingsStore), m_pDasherModel(new CDasherModel(this)), m_pFramerate(new CFrameRate(this)), m_pLockLabel(NULL) {
+CDasherInterfaceBase::CDasherInterfaceBase(CSettingsStore *pSettingsStore) : CSettingsUser(pSettingsStore), m_pSettingsStore(pSettingsStore), m_pDasherModel(new CDasherModel()), m_pFramerate(new CFrameRate(this)), m_pLockLabel(NULL) {
pSettingsStore->Register(this, true);
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index 45ba8fe..44d4a9e 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -50,8 +50,7 @@ static char THIS_FILE[] = __FILE__;
// CDasherModel
-CDasherModel::CDasherModel(CSettingsUser *pCreateFrom)
-: CSettingsUser(pCreateFrom) {
+CDasherModel::CDasherModel() {
m_pLastOutput = m_Root = NULL;
@@ -481,7 +480,7 @@ void CDasherModel::RenderToView(CDasherView *pView, CExpansionPolicy &policy) {
}
-void CDasherModel::ScheduleZoom(dasherint y1, dasherint y2) {
+void CDasherModel::ScheduleZoom(dasherint y1, dasherint y2, int nsteps) {
DASHER_ASSERT(y2>y1);
// Rename for readability.
@@ -517,7 +516,6 @@ void CDasherModel::ScheduleZoom(dasherint y1, dasherint y2) {
// sNewItem seems to contain a list of root{min,max} for the frames of the
// zoom, so split r -> R into n steps, with accurate R
- const int nsteps = GetLongParameter(LP_ZOOMSTEPS);
m_deGotoQueue.clear();
for (int s = nsteps - 1; s >= 0; --s) {
m_deGotoQueue.push_back(pair<myint,myint>(
diff --git a/Src/DasherCore/DasherModel.h b/Src/DasherCore/DasherModel.h
index 400e3bd..60e1961 100644
--- a/Src/DasherCore/DasherModel.h
+++ b/Src/DasherCore/DasherModel.h
@@ -50,11 +50,8 @@ namespace Dasher {
/// The DasherModel implements arithmetic coding for Dasher.
/// It contains a tree of DasherNodes and the current viewpoint,
/// and evolves the tree by expanding leaves (somewhat in response to DasherView) and
-/// (eventually) deleting ancestors/parents. It has two methods for moving around the tree:
-/// OneStepTowards implements steady motion towards a given point, one frame at a time;
-/// ScheduleZoom sets up movement to arrive at a particular point in a number of frames.
-/// Clients are responsible for monitoring framerate (if required) and using such
-/// information to decide how far to tell the DasherModel to move.
+/// (eventually) deleting ancestors/parents.
+
///
/// DasherModel does not care what the nodes in the tree are or mean, tho it does handle
/// calling CDasherNode::Output() / Undo() on nodes falling under/leaving the crosshair
@@ -62,7 +59,7 @@ namespace Dasher {
///
/// The class is Observable in that it broadcasts a pointer to a CDasherNode when the node's
/// children are created.
-class Dasher::CDasherModel: private CSettingsUser, public Observable<CDasherNode*>, private NoClones
+class Dasher::CDasherModel: public Observable<CDasherNode*>, private NoClones
{
public:
static const unsigned int NORMALIZATION = 1<<16;
@@ -70,7 +67,7 @@ class Dasher::CDasherModel: private CSettingsUser, public Observable<CDasherNode
/// Constructs a new CDasherModel. Note, must be followed by a call to
/// SetNode() before the model can be used.
- CDasherModel(CSettingsUser *pCreateFrom);
+ CDasherModel();
~CDasherModel();
/// @name Dymanic evolution
@@ -142,15 +139,14 @@ class Dasher::CDasherModel: private CSettingsUser, public Observable<CDasherNode
/// @{
///
- /// Schedule a zoom such that the given range of Dasher coordinates
- /// will fill the Y-axis. (used in click mode, button mode etc.)
- /// Note that this will take LP_ZOOM_STEPS frames to complete; safety margin,
- /// max-zoom, etc., as desired, are the responsibility of the caller
- /// (this method requires only that y2 > y1).
- /// \param y1 Minimum Y-coordinate (will be moved to dasher-y of 0)
- /// \param y2 Maximum Y-coordinate (will be moved to dasher-y of 4096)
- ///
- void ScheduleZoom(dasherint y1, dasherint y2);
+ /// Schedule a zoom over many frames, such that after the last frame,
+ /// the given range of Dasher coordinates (in the current view)
+ /// will fill the Y-axis. (Used by click mode, button mode etc.)
+ /// Note any safety margin, max-zoom, etc., are the responsibility
+ /// of the caller; this method requires only that y2 > y1.
+ /// \param y1,y2 - target range of y axis, i.e. to move to 0,MAXY
+ /// \param nSteps number of steps to schedule to take us all the way there
+ void ScheduleZoom(dasherint y1, dasherint y2, int nSteps);
///Cancel any steps previously scheduled (most likely by ScheduleZoom)
void ClearScheduledSteps();
diff --git a/Src/DasherCore/DynamicFilter.cpp b/Src/DasherCore/DynamicFilter.cpp
index 9984181..eb402f7 100644
--- a/Src/DasherCore/DynamicFilter.cpp
+++ b/Src/DasherCore/DynamicFilter.cpp
@@ -28,7 +28,7 @@ CDynamicFilter::CDynamicFilter(CSettingsUser *pCreator, CDasherInterfaceBase *pI
m_bPaused(true), m_pFramerate(pFramerate), m_dLastBits(-1) {
}
-bool CDynamicFilter::OneStepTowards(CDasherModel *pModel, myint y1, myint y2, unsigned long iTime, double dSpeedMul) {
+bool CDynamicFilter::OneStepTowards(CDasherModel *pModel, myint X, myint Y, unsigned long iTime, double dSpeedMul) {
if (dSpeedMul<=0.0) return false; //going nowhere
m_pFramerate->RecordFrame(iTime); //Hmmm, even if we don't do anything else?
@@ -50,7 +50,7 @@ bool CDynamicFilter::OneStepTowards(CDasherModel *pModel, myint y1, myint y2, un
// exp()s done in the dynamic button modes too, and thus to allow them to adjust
// lag, guide markers, etc., according to the dSpeedMul in use. (And/or
// to do slow-start more efficiently by interpolating cache values.)
- pModel->ScheduleOneStep(y1, y2,
+ pModel->ScheduleOneStep(X, Y,
static_cast<int>(m_pFramerate->Steps() / dSpeedMul),
m_iLastMinSize);
return true;
diff --git a/Src/DasherCore/DynamicFilter.h b/Src/DasherCore/DynamicFilter.h
index 67f217e..0f5c06a 100644
--- a/Src/DasherCore/DynamicFilter.h
+++ b/Src/DasherCore/DynamicFilter.h
@@ -49,7 +49,7 @@ class CDynamicFilter : public CInputFilter, public CSettingsUser {
/// 0.0 = go nowhere. This allows for slow start, turbo mode, control nodes being
/// more "viscous", etc. Values <=0.0 will result in no movement
/// \return true if dSpeedMul>0.0, false if <=0.0.
- bool OneStepTowards(CDasherModel *pModel, myint y1, myint y2, unsigned long iTime, double dSpeedMul);
+ bool OneStepTowards(CDasherModel *pModel, myint X, myint Y, unsigned long iTime, double dSpeedMul);
///Calculates a multiplier by which to adjust our speed (for a given frame).
/// Defalut implementation implements slow-start (i.e. a multiplier increasing
diff --git a/Src/DasherCore/InputFilter.h b/Src/DasherCore/InputFilter.h
index 33f60a1..6d4fb2b 100644
--- a/Src/DasherCore/InputFilter.h
+++ b/Src/DasherCore/InputFilter.h
@@ -69,16 +69,17 @@ class CInputFilter : public CDasherModule {
///Simple class, basis for filters using ScheduleZoom rather than
/// ScheduleOneStep, providing a ScheduleZoom method wrapping the
- /// DasherModel, such that pause() cancels any such zoom in progress.
- class CStaticFilter : public CInputFilter {
+ /// DasherModel one, using LP_ZOOMSTEPS steps and such that pause()
+ /// cancels any such zoom in progress.
+ class CStaticFilter : public CInputFilter, protected CSettingsUser {
public:
- CStaticFilter(CDasherInterfaceBase *pIntf, ModuleID_t iId, const char *szName)
- : CInputFilter(pIntf, iId, szName), m_pModel(NULL) {
+ CStaticFilter(CSettingsUser *pCreator, CDasherInterfaceBase *pIntf, ModuleID_t iId, const char *szName)
+ : CInputFilter(pIntf, iId, szName), CSettingsUser(pCreator), m_pModel(NULL) {
}
void pause() {if (m_pModel) m_pModel->ClearScheduledSteps();}
protected:
- void ScheduleZoom(CDasherModel *pModel, myint x, myint y) {
- (m_pModel = pModel)->ScheduleZoom(x,y);
+ void ScheduleZoom(CDasherModel *pModel, myint y1, myint y2) {
+ (m_pModel = pModel)->ScheduleZoom(y1,y2,GetLongParameter(LP_ZOOMSTEPS));
}
private:
CDasherModel *m_pModel;
diff --git a/Src/DasherCore/OneButtonFilter.cpp b/Src/DasherCore/OneButtonFilter.cpp
index b2a90af..fa7984a 100644
--- a/Src/DasherCore/OneButtonFilter.cpp
+++ b/Src/DasherCore/OneButtonFilter.cpp
@@ -15,7 +15,7 @@ static SModuleSettings sSettings[] = {
};
COneButtonFilter::COneButtonFilter(CSettingsUser *pCreator, CDasherInterfaceBase *pInterface)
- : CStaticFilter(pInterface, 9, "Static One Button Mode"), CSettingsUser(pCreator) {
+ : CStaticFilter(pCreator, pInterface, 9, "Static One Button Mode") {
bStarted = 0;
iLocation = 0;
diff --git a/Src/DasherCore/OneButtonFilter.h b/Src/DasherCore/OneButtonFilter.h
index 347e12b..037baae 100644
--- a/Src/DasherCore/OneButtonFilter.h
+++ b/Src/DasherCore/OneButtonFilter.h
@@ -6,7 +6,7 @@
namespace Dasher {
/// \ingroup InputFilter
/// @{
-class COneButtonFilter : public CStaticFilter, private CSettingsUser {
+class COneButtonFilter : public CStaticFilter {
public:
COneButtonFilter(CSettingsUser *pCreator, CDasherInterfaceBase *pInterface);
diff --git a/Src/DasherCore/StylusFilter.cpp b/Src/DasherCore/StylusFilter.cpp
index 2caa57b..e215fa7 100644
--- a/Src/DasherCore/StylusFilter.cpp
+++ b/Src/DasherCore/StylusFilter.cpp
@@ -30,7 +30,7 @@ void CStylusFilter::KeyUp(unsigned long iTime, int iId, CDasherView *pView, CDas
if (iTime - m_iKeyDownTime < GetLongParameter(LP_TAP_TIME)) {
pInput->GetDasherCoords(m_iLastX, m_iLastY, pView);
ApplyClickTransform(m_iLastX, m_iLastY, pView);
- (m_pModel=pModel)->ScheduleZoom(m_iLastY-m_iLastX, m_iLastY+m_iLastX);
+ (m_pModel=pModel)->ScheduleZoom(m_iLastY-m_iLastX, m_iLastY+m_iLastX, GetLongParameter(LP_ZOOMSTEPS));
} else {
m_pInterface->Done();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]