Author: derek Date: Thu Jul 19 19:58:24 2007 New Revision: 359 Modified: sofaswitch/trunk/callflow/src/joinblocks.cpp Log: fix the calculation of testing the joinblocks structure and if it intersects with the selection rectangle. Modified: sofaswitch/trunk/callflow/src/joinblocks.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/joinblocks.cpp (original) +++ sofaswitch/trunk/callflow/src/joinblocks.cpp Thu Jul 19 19:58:24 2007 @@ -223,6 +223,13 @@ bool doCross = (cross >= MIN(ptA.y, ptB.y)) && (cross <= MAX (ptA.y, ptB.y)); +#if 0 + if (doCross) { + std::cerr << "CROSS " << ptA.x << "." << ptA.y << "--" << ptB.x << "." << ptB.y << std::endl; + std::cerr << "CROSS " << ptY.x << "." << ptY.y << "--" << ptZ.x << "." << ptZ.y << std::endl; + } +#endif + return doCross; } @@ -238,10 +245,19 @@ double cross = (abC - yzC) / (yzM - abM); double crossY = (cross * abM) + abC; //std::cerr << "Cross Y is " << crossY << std::endl; - bool doCross = (crossY >= MIN(ptA.y, ptB.y)) && (crossY <= MAX (ptA.y, ptB.y)) + bool doCrossY = (crossY >= MIN(ptA.y, ptB.y)) && (crossY <= MAX (ptA.y, ptB.y)) && (crossY >= MIN(ptY.y, ptZ.y)) && (crossY <= MAX (ptY.y, ptZ.y)); - return doCross; + bool doCrossX = (cross >= MIN(ptA.x, ptB.x)) && (cross <= MAX (ptA.x, ptB.x)) + && (cross >= MIN(ptY.x, ptZ.x)) && (cross <= MAX (ptY.x, ptZ.x)); +#if 0 + if (doCrossX && doCrossY) { + std::cerr << "CROSS " << ptA.x << "." << ptA.y << "--" << ptB.x << "." << ptB.y << std::endl; + std::cerr << "CROSS " << ptY.x << "." << ptY.y << "--" << ptZ.x << "." << ptZ.y << std::endl; + } +#endif + + return doCrossX && doCrossY; } @@ -277,24 +293,21 @@ if (node == NULL) return false; - if ((testRectangle.x == 0) && (testRectangle.y == 0)) - return true; - - wxRect markedRectangle = testRectangle.Inflate(5, 5); + wxRect markedRectangle = testRectangle.Inflate(2, 2); #if 0 std::cerr << " compare rectangle " << testRectangle.x << "."<<testRectangle.y << "---" << testRectangle.GetWidth() << "x" << testRectangle.GetHeight() << std::endl; std::cerr << " compare rectangle " << markedRectangle.x << "."<< markedRectangle.y << "---" << markedRectangle.GetWidth() << "x" << markedRectangle.GetHeight() << std::endl; -#endif while (node != NULL) { wxPoint aPoint = *((wxPoint *)node->GetData()); -// std::cerr << aPoint.x << "." << aPoint.y <<" "; + std::cerr << aPoint.x << "." << aPoint.y <<" "; node = node->GetNext(); } -// std::cerr << std::endl; + std::cerr << std::endl; +#endif node = (wxNode *)points.GetFirst(); while(node != NULL) { @@ -306,7 +319,7 @@ isInside = markedRectangle.Inside(thisPoint); #endif if (isInside) { -// std::cerr << "point " << thisPoint.x << " " << thisPoint.y << " is inside\n"; + //std::cerr << "point " << thisPoint.x << " " << thisPoint.y << " is inside\n"; return true; } node = node->GetNext(); @@ -318,7 +331,7 @@ wxPoint mRc(mRb.x, mRb.y + markedRectangle.GetHeight()); wxPoint mRd(mRa.x, mRc.y); -#if 0 +#if 0 std::cerr << " Rectangle is " << mRa.x <<"." <<mRa.y <<" " << mRb.x <<"." <<mRb.y <<" " @@ -339,7 +352,7 @@ } if (LinesDoCross(mRb, mRc, firstPoint, thisPoint)) { - //std::cerr << "lnes do cross right edge \n"; + //std::cerr << "lines do cross right edge \n"; return true; }