[dasher] Fix socket input to not mirror and lower number of nodes with letters.



commit 09ffc9981648f0cd504a7c5592580e19e1b48f48
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Tue Mar 15 17:09:31 2011 +0000

    Fix socket input to not mirror and lower number of nodes with letters.

 Src/DasherCore/DasherViewSquare.cpp |   30 +++---------------------------
 Src/DasherCore/SocketInputBase.cpp  |    2 +-
 Src/DasherCore/SocketInputBase.h    |   16 ++++++++--------
 3 files changed, 12 insertions(+), 36 deletions(-)
---
diff --git a/Src/DasherCore/DasherViewSquare.cpp b/Src/DasherCore/DasherViewSquare.cpp
index fbe04c4..3384493 100644
--- a/Src/DasherCore/DasherViewSquare.cpp
+++ b/Src/DasherCore/DasherViewSquare.cpp
@@ -733,13 +733,8 @@ beginning:
     //if child still covers screen, render _just_ it and return
     myint newy1 = y1 + (Range * (myint)pChild->Lbnd()) / (myint)norm;
     myint newy2 = y1 + (Range * (myint)pChild->Hbnd()) / (myint)norm;
-    //we also check whether the "only" child to render is too small to render normally.
-    // this is the case IF all the others were smaller, in which case only the "only"
-    // one should be rendered. (Unfortunately, IF but not & ONLY IF...hoping this is
-    // too infrequent to worry.)
-    if ((newy2-newy1 < GetLongParameter(LP_MIN_NODE_SIZE) //too small, but stored as only - so all others are smaller still...
-		 && newy1 <= iDasherMaxY && newy2 >= iDasherMinY) //check too-small node is at least partly onscreen
-	    || (newy1 < iDasherMinY && newy2 > iDasherMaxY)) { //covers entire y-axis!
+    if (
+	    (newy1 < iDasherMinY && newy2 > iDasherMaxY)) { //covers entire y-axis!
          //render just that child; nothing more to do for this node => tail call to beginning
          pRender = pChild; y1=newy1; y2=newy2;
          parent_color = myColor;
@@ -749,7 +744,7 @@ beginning:
   }
     
   //ok, need to render all children...
-  myint newy1=y1,newy2; unsigned int bestRange(norm/3); CDasherNode *pBestCh(NULL);
+  myint newy1=y1,newy2;
   CDasherNode::ChildMap::const_iterator I = pRender->GetChildren().begin(), E = pRender->GetChildren().end();
   while (I!=E) {
     CDasherNode *pChild(*I);
@@ -764,11 +759,6 @@ beginning:
           if (newy1 < iDasherMinY) pRender->onlyChildRendered = pChild; //...and previous were too!
           break; //skip remaining children...
         }
-        bestRange = norm+1; //impossible value, used as sentinel to mean some child was rendered
-      } else if (pChild->Range() > bestRange) {
-        //record the largest child, if none has been rendered
-        if (pBestCh && !pBestCh->GetFlag(NF_GAME | NF_SEEN)) pBestCh->Delete_children();
-        pBestCh = pChild; bestRange = pChild->Range();
       } else {
         //did not recurse, or store
         if (!pChild->GetFlag(NF_GAME | NF_SEEN)) pChild->Delete_children();
@@ -782,20 +772,6 @@ beginning:
     //broke out of loop. Possibly more to delete...
     while (++I!=E) if (!(*I)->GetFlag(NF_GAME | NF_SEEN)) (*I)->Delete_children();
   }
-  //lastly. We may have recorded a "biggest but still too small" node to render.
-  if (pBestCh) {
-    if (bestRange <= norm) {
-      //yup - no child big enough outright, so render the biggest
-      pRender->onlyChildRendered = pBestCh; //cache for next time - the IF but not ONLY IF, above :-(
-      //and make tail call to beginning, as nothing more to do for the current node
-      pRender = pBestCh;
-      parent_color = myColor;
-      y2 = y1 + (Range * (myint)pRender->Hbnd())/(myint)norm;
-      y1+=(Range*(myint)pRender->Lbnd())/(myint)norm;
-      goto beginning;
-    } else if (!pBestCh->GetFlag(NF_GAME | NF_SEEN))
-      pBestCh->Delete_children();
-  }
   //all children rendered.
 }
 
diff --git a/Src/DasherCore/SocketInputBase.cpp b/Src/DasherCore/SocketInputBase.cpp
index 330858a..e54f619 100644
--- a/Src/DasherCore/SocketInputBase.cpp
+++ b/Src/DasherCore/SocketInputBase.cpp
@@ -35,7 +35,7 @@ static SModuleSettings sSettings[] = {
 };
 
 Dasher::CSocketInputBase::CSocketInputBase(CEventHandler * pEventHandler, CSettingsStore * pSettingsStore) 
-  : CDasherCoordInput(pEventHandler, pSettingsStore, 1, _("Socket Input")) {
+  : CScreenCoordInput(pEventHandler, pSettingsStore, 1, _("Socket Input")) {
   port = -1;
   debug_socket_input = false;
   readerRunning = false;
diff --git a/Src/DasherCore/SocketInputBase.h b/Src/DasherCore/SocketInputBase.h
index c5cc2b0..80a023a 100644
--- a/Src/DasherCore/SocketInputBase.h
+++ b/Src/DasherCore/SocketInputBase.h
@@ -22,7 +22,7 @@ namespace Dasher {
 using namespace std;
 /// \ingroup Input 
 /// \{
-class CSocketInputBase : public CDasherCoordInput {
+class CSocketInputBase : public CScreenCoordInput {
 
 public:
 
@@ -55,19 +55,19 @@ public:
 
   /// Gets the last coordinates received; if only one coordinate is being read, this is put
   /// into iDasherY (and iDasherX set to 0).
-  bool GetDasherCoords(myint &iDasherX, myint &iDasherY, CDasherView *pView) {
+  bool GetScreenCoords(screenint &iScreenX, screenint &iScreenY, CDasherView *pView) {
     
     //update max values for reader thread...(note any changes here won't be incorporated
     // until values are next received over socket, but never mind)
-    myint iDasherMinX, iDasherMinY;
-    pView->VisibleRegion(iDasherMinX, iDasherMinY, dasherMaxCoordinateValues[0], dasherMaxCoordinateValues[1]);
+    dasherMaxCoordinateValues[0] = pView->Screen()->GetWidth();
+    dasherMaxCoordinateValues[1] = pView->Screen()->GetHeight();
     
     if (coordinateCount==1) {
-      iDasherX = 0;
-      iDasherY = dasherCoordinates[0];
+      iScreenX = 0;
+      iScreenY = dasherCoordinates[0];
     } else if (coordinateCount==2) {
-      iDasherX = dasherCoordinates[0];
-      iDasherY = dasherCoordinates[1];
+      iScreenX = dasherCoordinates[0];
+      iScreenY = dasherCoordinates[1];
     } else {
       //Aiieee, we're receiving >2 coords? Don't know what to do...
       return false;



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