Logo Search packages:      
Sourcecode: ktechlab version File versions

void ConRouter::setPoints ( const QPointList &  pointList,
bool  reverse = false 
)

Sets the route to the given canvas points

Parameters:
reverse if true, the points in pointList will be reversed

Definition at line 237 of file conrouter.cpp.

References cellPointList(), and removeDuplicatePoints().

Referenced by Connector::setRoutePoints().

{
      if (  pointList.size() == 0 ) return;

      QPointList cellPointList;

      QPoint prevCellPoint = fromCanvas(*pointList.begin());
      cellPointList.append(prevCellPoint);
      const QPointList::const_iterator end = pointList.end();
      for ( QPointList::const_iterator it = pointList.begin(); it != end; ++it )
      {
            QPoint cellPoint = fromCanvas(*it);
            
            while ( prevCellPoint != cellPoint )
            {
                  cellPointList.append(prevCellPoint);
                  
                  if          ( prevCellPoint.x() < cellPoint.x() ) prevCellPoint.setX( prevCellPoint.x()+1 );
                  else if ( prevCellPoint.x() > cellPoint.x() ) prevCellPoint.setX( prevCellPoint.x()-1 );
                  if          ( prevCellPoint.y() < cellPoint.y() ) prevCellPoint.setY( prevCellPoint.y()+1 );
                  else if ( prevCellPoint.y() > cellPoint.y() ) prevCellPoint.setY( prevCellPoint.y()-1 );
            };
            
            prevCellPoint = cellPoint;
      }
      cellPointList.append(prevCellPoint);
      
      if (reverse)
      {
            m_cellPointList.clear();
            const QPointList::iterator begin = cellPointList.begin();
            for ( QPointList::iterator it = cellPointList.fromLast(); it != begin; --it )
            {
                  m_cellPointList += *it;
            }
            m_cellPointList += *begin;
      } else {
            m_cellPointList = cellPointList;
      }
      
      removeDuplicatePoints();
}


Generated by  Doxygen 1.6.0   Back to index