[dasher] Added CScreenGeomEvent, broadcast whenever Dasher-/Screen-coord mapping changes



commit b2bd7327b591bd5b01106e1db9e6d2fbe6885b18
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Wed Feb 23 18:37:42 2011 +0000

    Added CScreenGeomEvent, broadcast whenever Dasher-/Screen-coord mapping changes
    
    Fixes circle start handler location when screen resized.
    
    TODO, there are probably lots of places where we can+should cache transformed
     (screen) coordinates, rather than recomputing every frame...
    
    Also move CDasherView::m_bVisibleRegionValid => CDasherViewSquare & tidy c'tor.

 Src/DasherCore/CircleStartHandler.cpp |    5 ++++-
 Src/DasherCore/DasherView.h           |    5 -----
 Src/DasherCore/DasherViewSquare.cpp   |   14 +++++---------
 Src/DasherCore/DasherViewSquare.h     |    2 ++
 Src/DasherCore/Event.h                |   13 ++++++++++++-
 5 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/Src/DasherCore/CircleStartHandler.cpp b/Src/DasherCore/CircleStartHandler.cpp
index c363934..5da2c7f 100644
--- a/Src/DasherCore/CircleStartHandler.cpp
+++ b/Src/DasherCore/CircleStartHandler.cpp
@@ -105,7 +105,7 @@ void CCircleStartHandler::HandleEvent(Dasher::CEvent * pEvent) {
     switch (pEvt->m_iParameter) {
     case LP_REAL_ORIENTATION:
     case LP_CIRCLE_PERCENT:
-      //recompute geometry. TODO, need to trap arbitrary screen geom changes too...?
+      //recompute geometry.
       m_iScreenRadius = -1;
       break;
     case BP_DASHER_PAUSED:
@@ -117,5 +117,8 @@ void CCircleStartHandler::HandleEvent(Dasher::CEvent * pEvent) {
       m_bInCircle = true;
       break;
     }
+  } else if (pEvent->m_iEventType == EV_SCREEN_GEOM) {
+    //need to recompute geometry (in next DecorateView or Timer)
+    m_iScreenRadius = -1;
   }
 }
diff --git a/Src/DasherCore/DasherView.h b/Src/DasherCore/DasherView.h
index 760ed87..b7b8e6e 100644
--- a/Src/DasherCore/DasherView.h
+++ b/Src/DasherCore/DasherView.h
@@ -161,11 +161,6 @@ protected:
   /// will then add exactly one CDasherScreen::point for each line segment required.
   virtual void DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, std::vector<CDasherScreen::point> &vPoints)=0;
   
-  // Orientation of Dasher Screen
-/*   inline void MapScreen(screenint * DrawX, screenint * DrawY); */
-/*   inline void UnMapScreen(screenint * DrawX, screenint * DrawY); */
-  bool m_bVisibleRegionValid;
-  
   ///Number of nodes actually rendered. Updated only by subclasses; TODO does
   /// this belong here? (perhaps for subclass-agnostic clients to inspect...)
   int m_iRenderCount;
diff --git a/Src/DasherCore/DasherViewSquare.cpp b/Src/DasherCore/DasherViewSquare.cpp
index 6e5be20..fbe04c4 100644
--- a/Src/DasherCore/DasherViewSquare.cpp
+++ b/Src/DasherCore/DasherViewSquare.cpp
@@ -59,17 +59,10 @@ static char THIS_FILE[] = __FILE__;
 // FIXME - duplicated 'mode' code throught - needs to be fixed (actually, mode related stuff, Input2Dasher etc should probably be at least partially in some other class)
 
 CDasherViewSquare::CDasherViewSquare(CEventHandler *pEventHandler, CSettingsStore *pSettingsStore, CDasherScreen *DasherScreen)
-: CDasherView(pEventHandler, pSettingsStore, DasherScreen),   m_Y1(4), m_Y2(0.95 * GetLongParameter(LP_MAX_Y)), m_Y3(0.05 * GetLongParameter((LP_MAX_Y))) {
-
-  // TODO - AutoOffset should be part of the eyetracker input filter
-  // Make sure that the auto calibration is set to zero berfore we start
-  //  m_yAutoOffset = 0;
-
-  ChangeScreen(DasherScreen);
+: CDasherView(pEventHandler, pSettingsStore, DasherScreen),   m_Y1(4), m_Y2(0.95 * GetLongParameter(LP_MAX_Y)), m_Y3(0.05 * GetLongParameter((LP_MAX_Y))), m_bVisibleRegionValid(false) {
 
   //Note, nonlinearity parameters set in SetScaleFactor 
-  m_bVisibleRegionValid = false;
-  
+  ChangeScreen(DasherScreen);
 }
 
 CDasherViewSquare::~CDasherViewSquare() {}
@@ -936,6 +929,9 @@ void CDasherViewSquare::SetScaleFactor( void )
       std::cout << "ERROR ScreenY " << y << " becomes " << dy << " back to " << fy << std::endl;
   }
 #endif
+  
+  CScreenGeomEvent evt;
+  InsertEvent(&evt);
 }
 
 
diff --git a/Src/DasherCore/DasherViewSquare.h b/Src/DasherCore/DasherViewSquare.h
index bb25700..65eae5e 100644
--- a/Src/DasherCore/DasherViewSquare.h
+++ b/Src/DasherCore/DasherViewSquare.h
@@ -192,6 +192,8 @@ private:
   inline myint CustomIDiv(myint iNumerator, myint iDenominator);
 
   void DasherLine2Screen(myint x1, myint y1, myint x2, myint y2, vector<CDasherScreen::point> &vPoints);
+
+  bool m_bVisibleRegionValid;
   
   // Called on screen size or orientation changes
   void SetScaleFactor();
diff --git a/Src/DasherCore/Event.h b/Src/DasherCore/Event.h
index 6b109d4..2c2de66 100644
--- a/Src/DasherCore/Event.h
+++ b/Src/DasherCore/Event.h
@@ -14,10 +14,11 @@ namespace Dasher {
   class CControlEvent;
   class CLockEvent;
   class CMessageEvent;
+  class CScreenGeomEvent;
 }
 
 enum {
-  EV_PARAM_NOTIFY = 1, EV_EDIT, EV_EDIT_CONTEXT, EV_CONTROL, EV_LOCK, EV_MESSAGE
+  EV_PARAM_NOTIFY = 1, EV_EDIT, EV_EDIT_CONTEXT, EV_CONTROL, EV_LOCK, EV_MESSAGE, EV_SCREEN_GEOM
 };
 
 /// \ingroup Core
@@ -93,6 +94,16 @@ public:
   const int m_iID;
   const int m_iType;
 };
+
+///Generated whenever the screen geometry changes: e.g. aspect ratio,
+/// size, degree of nonlinearity, orientation, or generally whenever
+/// values returned by Dasher2Screen/Screen2Dasher might have changed
+/// (thus, any code caching such values should recompute/invalidate them)
+class Dasher::CScreenGeomEvent : public Dasher::CEvent {
+public:
+  CScreenGeomEvent() : CEvent(EV_SCREEN_GEOM) {
+  }
+};
 /// @}
 /// @}
 



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