summaryrefslogtreecommitdiffstats
path: root/src/conrouter.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-29 16:05:55 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-29 16:05:55 +0000
commit87a016680e3677da3993f333561e79eb0cead7d5 (patch)
treecbda2b4df8b8ee0d8d1617e6c75bec1e3ee0ccba /src/conrouter.cpp
parent6ce3d1ad09c1096b5ed3db334e02859e45d5c32b (diff)
downloadktechlab-87a016680e3677da3993f333561e79eb0cead7d5.tar.gz
ktechlab-87a016680e3677da3993f333561e79eb0cead7d5.zip
TQt4 port ktechlab
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktechlab@1238801 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/conrouter.cpp')
-rw-r--r--src/conrouter.cpp108
1 files changed, 54 insertions, 54 deletions
diff --git a/src/conrouter.cpp b/src/conrouter.cpp
index 2c2d6da..d09bb81 100644
--- a/src/conrouter.cpp
+++ b/src/conrouter.cpp
@@ -25,22 +25,22 @@ inline static int fromCanvas( int pos )
return (pos-4)/8;
}
-inline static QPoint toCanvas( const QPoint * const pos )
+inline static TQPoint toCanvas( const TQPoint * const pos )
{
- return QPoint( toCanvas(pos->x()), toCanvas(pos->y()) );
+ return TQPoint( toCanvas(pos->x()), toCanvas(pos->y()) );
}
-inline static QPoint fromCanvas( const QPoint * const pos )
+inline static TQPoint fromCanvas( const TQPoint * const pos )
{
- return QPoint( fromCanvas(pos->x()), fromCanvas(pos->y()) );
+ return TQPoint( fromCanvas(pos->x()), fromCanvas(pos->y()) );
}
-inline static QPoint toCanvas( const QPoint &pos )
+inline static TQPoint toCanvas( const TQPoint &pos )
{
- return QPoint( toCanvas(pos.x()), toCanvas(pos.y()) );
+ return TQPoint( toCanvas(pos.x()), toCanvas(pos.y()) );
}
-inline static QPoint fromCanvas( const QPoint &pos )
+inline static TQPoint fromCanvas( const TQPoint &pos )
{
- return QPoint( fromCanvas(pos.x()), fromCanvas(pos.y()) );
+ return TQPoint( fromCanvas(pos.x()), fromCanvas(pos.y()) );
}
static inline int roundDouble( const double x )
@@ -60,14 +60,14 @@ ConRouter::~ConRouter()
}
-QPointList ConRouter::pointList( bool reverse ) const
+TQPointList ConRouter::pointList( bool reverse ) const
{
- QPointList pointList;
+ TQPointList pointList;
if (reverse)
{
bool notDone = m_cellPointList.size() > 0;
- for ( QPointList::const_iterator it = m_cellPointList.fromLast(); notDone; --it )
+ for ( TQPointList::const_iterator it = m_cellPointList.fromLast(); notDone; --it )
{
pointList.append( toCanvas(&*it) );
if ( it == m_cellPointList.begin() ) notDone = false;
@@ -75,8 +75,8 @@ QPointList ConRouter::pointList( bool reverse ) const
}
else
{
- const QPointList::const_iterator end = m_cellPointList.end();
- for ( QPointList::const_iterator it = m_cellPointList.begin(); it != end; ++it )
+ const TQPointList::const_iterator end = m_cellPointList.end();
+ for ( TQPointList::const_iterator it = m_cellPointList.begin(); it != end; ++it )
{
pointList.append( toCanvas(&*it) );
}
@@ -86,7 +86,7 @@ QPointList ConRouter::pointList( bool reverse ) const
}
-static double qpoint_distance( const QPoint & p1, const QPoint & p2 )
+static double qpoint_distance( const TQPoint & p1, const TQPoint & p2 )
{
double dx = p1.x() - p2.x();
double dy = p1.y() - p2.y();
@@ -95,28 +95,28 @@ static double qpoint_distance( const QPoint & p1, const QPoint & p2 )
}
-QPointListList ConRouter::splitPoints( const QPoint &pos ) const
+TQPointListList ConRouter::splitPoints( const TQPoint &pos ) const
{
- const QPoint split = fromCanvas(&pos);
+ const TQPoint split = fromCanvas(&pos);
- QValueList<QPointList> list;
+ TQValueList<TQPointList> list;
// Check that the point is in the connector points, and not at the start or end
bool found = false;
- QPointList::const_iterator end = m_cellPointList.end();
+ TQPointList::const_iterator end = m_cellPointList.end();
double dl[] = { 0.0, 1.1, 1.5 }; // sqrt(2) < 1.5 < sqrt(5)
for ( unsigned i = 0; (i < 3) && !found; ++i )
{
- for ( QPointList::const_iterator it = m_cellPointList.begin(); it != end && !found; ++it )
+ for ( TQPointList::const_iterator it = m_cellPointList.begin(); it != end && !found; ++it )
{
if ( qpoint_distance( *it, split ) <= dl[i] && it != m_cellPointList.begin() && it != m_cellPointList.fromLast() )
found = true;
}
}
- QPointList first;
- QPointList second;
+ TQPointList first;
+ TQPointList second;
if (!found)
{
@@ -136,9 +136,9 @@ QPointListList ConRouter::splitPoints( const QPoint &pos ) const
// Now add the points to the two lists
bool gotToSplit = false;
- for ( QPointList::const_iterator it = m_cellPointList.begin(); it != end; ++it )
+ for ( TQPointList::const_iterator it = m_cellPointList.begin(); it != end; ++it )
{
- QPoint canvasPoint = toCanvas(&*it);
+ TQPoint canvasPoint = toCanvas(&*it);
if ( *it == split )
{
gotToSplit = true;
@@ -162,27 +162,27 @@ QPointListList ConRouter::splitPoints( const QPoint &pos ) const
}
-QPointListList ConRouter::dividePoints( uint n ) const
+TQPointListList ConRouter::dividePoints( uint n ) const
{
// Divide the points up into n pieces...
- QPointList points = m_cellPointList;
+ TQPointList points = m_cellPointList;
assert( n != 0 );
if ( points.size() == 0 ) {
- points += QPoint( toCanvas(m_lcx), toCanvas(m_lcy) );
+ points += TQPoint( toCanvas(m_lcx), toCanvas(m_lcy) );
}
const float avgLength = float(points.size()-1)/float(n);
- QPointListList pll;
+ TQPointListList pll;
for ( uint i=0; i<n; ++i )
{
- QPointList pl;
+ TQPointList pl;
// Get the points between (pos) and (pos+avgLength)
const int endPos = roundDouble( avgLength*(i+1) );
const int startPos = roundDouble( avgLength*i );
- const QPointList::iterator end = ++points.at(endPos);
- for ( QPointList::iterator it = points.at(startPos); it != end; ++it )
+ const TQPointList::iterator end = ++points.at(endPos);
+ for ( TQPointList::iterator it = points.at(startPos); it != end; ++it )
{
pl += toCanvas(*it);
}
@@ -273,26 +273,26 @@ bool ConRouter::needsRouting( int sx, int sy, int ex, int ey ) const
}
-void ConRouter::setRoutePoints( const QPointList &pointList )
+void ConRouter::setRoutePoints( const TQPointList &pointList )
{
m_cellPointList = pointList;
removeDuplicatePoints();
}
-void ConRouter::setPoints( const QPointList &pointList, bool reverse )
+void ConRouter::setPoints( const TQPointList &pointList, bool reverse )
{
if ( pointList.size() == 0 )
return;
- QPointList cellPointList;
+ TQPointList cellPointList;
- QPoint prevCellPoint = fromCanvas(*pointList.begin());
+ TQPoint prevCellPoint = fromCanvas(*pointList.begin());
cellPointList.append(prevCellPoint);
- const QPointList::const_iterator end = pointList.end();
- for ( QPointList::const_iterator it = pointList.begin(); it != end; ++it )
+ const TQPointList::const_iterator end = pointList.end();
+ for ( TQPointList::const_iterator it = pointList.begin(); it != end; ++it )
{
- QPoint cellPoint = fromCanvas(*it);
+ TQPoint cellPoint = fromCanvas(*it);
while ( prevCellPoint != cellPoint )
{
@@ -311,8 +311,8 @@ void ConRouter::setPoints( const QPointList &pointList, bool reverse )
if (reverse)
{
m_cellPointList.clear();
- const QPointList::iterator begin = cellPointList.begin();
- for ( QPointList::iterator it = cellPointList.fromLast(); it != begin; --it )
+ const TQPointList::iterator begin = cellPointList.begin();
+ for ( TQPointList::iterator it = cellPointList.fromLast(); it != begin; --it )
{
m_cellPointList += *it;
}
@@ -335,11 +335,11 @@ void ConRouter::translateRoute( int dx, int dy )
m_lcx += dx;
m_lcy += dy;
-// const QPoint ds = QPoint( fromCanvas(dx), fromCanvas(dy) );
- const QPoint ds = QPoint( dx/8, dy/8 );
+// const TQPoint ds = TQPoint( fromCanvas(dx), fromCanvas(dy) );
+ const TQPoint ds = TQPoint( dx/8, dy/8 );
- QPointList::iterator end = m_cellPointList.end();
- for ( QPointList::iterator it = m_cellPointList.begin(); it != end; ++it )
+ TQPointList::iterator end = m_cellPointList.end();
+ for ( TQPointList::iterator it = m_cellPointList.begin(); it != end; ++it )
{
(*it) += ds;
}
@@ -443,7 +443,7 @@ void ConRouter::mapRoute( int sx, int sy, int ex, int ey )
bool ok = true;
do
{
- m_cellPointList.append( QPoint( x, y ) );
+ m_cellPointList.append( TQPoint( x, y ) );
int newx = (*cellsPtr)[x][y].prevX;
int newy = (*cellsPtr)[x][y].prevY;
if ( newx == x && newy == y ) {
@@ -455,7 +455,7 @@ void ConRouter::mapRoute( int sx, int sy, int ex, int ey )
while ( p_icnDocument->isValidCellReference(x,y) && x != -1 && y != -1 && ok );
// And append the last point...
- m_cellPointList.append( QPoint( ecx, ecy ) );
+ m_cellPointList.append( TQPoint( ecx, ecy ) );
}
removeDuplicatePoints();
@@ -496,7 +496,7 @@ bool ConRouter::checkLineRoute( int scx, int scy, int ecx, int ecy, int maxConSc
{
return false;
} else {
- m_cellPointList.append( QPoint( x, y ) );
+ m_cellPointList.append( TQPoint( x, y ) );
}
}
}
@@ -508,13 +508,13 @@ bool ConRouter::checkLineRoute( int scx, int scy, int ecx, int ecy, int maxConSc
{
return false;
} else {
- m_cellPointList.append( QPoint( x, y ) );
+ m_cellPointList.append( TQPoint( x, y ) );
}
}
}
- m_cellPointList.prepend( QPoint( scx, scy ) );
- m_cellPointList.append( QPoint( ecx, ecy ) );
+ m_cellPointList.prepend( TQPoint( scx, scy ) );
+ m_cellPointList.append( TQPoint( ecx, ecy ) );
removeDuplicatePoints();
return true;
}
@@ -522,16 +522,16 @@ bool ConRouter::checkLineRoute( int scx, int scy, int ecx, int ecy, int maxConSc
void ConRouter::removeDuplicatePoints()
{
- QPoint prev(-1,-1);
+ TQPoint prev(-1,-1);
- const QPointList::iterator end = m_cellPointList.end();
- for ( QPointList::iterator it = m_cellPointList.begin(); it != end; ++it )
+ const TQPointList::iterator end = m_cellPointList.end();
+ for ( TQPointList::iterator it = m_cellPointList.begin(); it != end; ++it )
{
if ( *it == prev ) {
- *it = QPoint(-1,-1);
+ *it = TQPoint(-1,-1);
} else {
prev = *it;
}
}
- m_cellPointList.remove( QPoint(-1,-1) );
+ m_cellPointList.remove( TQPoint(-1,-1) );
}