Logo Search packages:      
Sourcecode: ktechlab version File versions

void Connector::updateConnectorPoints ( bool  add  )  [inherited]

ICNDocument needs to know what 'cells' a connector is present in, so that connection mapping can be done to avoid connectors. This function will add the hit penalty to the cells pointed to by ICNDocument::cells()

Definition at line 278 of file connector.cpp.

References ICNDocument::addCPenalty(), Cells::cell(), ConRouter::cellPointList(), ICNDocument::cells(), and Cells::haveCell().

Referenced by FlowICNDocument::createConnector(), CircuitICNDocument::createConnector(), FlowICNDocument::joinConnectors(), CircuitICNDocument::joinConnectors(), Connector::rerouteConnector(), Connector::restoreFromConnectorData(), Connector::setRoutePoints(), Connector::translateRoute(), and NodeGroup::updateRoutes().

                                              {
      if (!canvas()) return;

      if (b_deleted || !isVisible()) add = false;

      // Check we haven't already added/removed the points...
      if (b_pointsAdded == add) return;

      b_pointsAdded = add;

      // We don't include the end points in the mapping
      if (m_conRouter->cellPointList()->size() < 3) return;

      Cells * cells = p_icnDocument->cells();

      const int mult = (add) ? 1 : -1;
      const QPointList::iterator end = --m_conRouter->cellPointList()->end();

      for (QPointList::iterator it = ++m_conRouter->cellPointList()->begin(); it != end; ++it) {
            int x = (*it).x();
            int y = (*it).y();

            // Add the points of this connector to the cell array in the ICNDocument,
            // so that other connectors still to calculate their points know to try
            // and avoid this connector

            p_icnDocument->addCPenalty(x    , y - 1, mult*ICNDocument::hs_connector / 2);
            p_icnDocument->addCPenalty(x - 1, y    , mult*ICNDocument::hs_connector / 2);
            p_icnDocument->addCPenalty(x    , y    , mult*ICNDocument::hs_connector    );
            p_icnDocument->addCPenalty(x + 1, y    , mult*ICNDocument::hs_connector / 2);
            p_icnDocument->addCPenalty(x    , y + 1, mult*ICNDocument::hs_connector / 2);

            if (cells->haveCell(x , y))
                  cells->cell(x, y).numCon += mult;
      }

//    updateDrawList();
}


Generated by  Doxygen 1.6.0   Back to index