Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

Connector * ICNDocument::createConnector ( Node node,
Connector con,
const QPoint &  pos2,
QPointList *  pointList = 0L 
) [inherited]

Splits Connector con into two connectors at point pos2, and creates a connector from the node to the intersection of the two new connectors. If pointList is non-null, then the new connector from the node will be assigned those points

Definition at line 370 of file icndocument.cpp.

References ICNDocument::addAllItemConnectorPoints(), Node::addOutputConnector(), ICNDocument::canConnect(), Node::createInputConnector(), ICNDocument::createNodeGroup(), ICNDocument::deleteNodeGroup(), Connector::endNode(), ICNDocument::flushDeleteList(), NodeGroup::init(), ConRouter::mapRoute(), ConRouter::pointList(), Connector::removeConnector(), Connector::setRoutePoints(), Connector::splitConnectorPoints(), Connector::startNode(), Document::type(), Connector::updateConnectorPoints(), Connector::updateDrawList(), and Connector::usesManualPoints().

{
      if ( !canConnect( node, con ) )
            return 0l;
      
      Node *conStartNode = con->startNode();
      Node *conEndNode = con->endNode();
      
      const bool usedManual = con->usesManualPoints();
      
      Node *newNode = 0l;
      if ( type() == Document::dt_circuit )
            newNode = new ECNode( this, Node::ec_junction, Node::dir_right, pos2 );
      
      else if ( type() == Document::dt_flowcode )
            newNode = new FPNode( this, Node::fp_junction, Node::dir_right, pos2 );
      
      else
            return 0l;
      
      QPointList autoPoints;
      if (!pointList)
      {
            addAllItemConnectorPoints();
            ConRouter cr(this);
            cr.mapRoute( int(node->x()), int(node->y()), pos2.x(), pos2.y() );
            autoPoints = cr.pointList(false);
            pointList = &autoPoints;
      }
      
      QValueList<QPointList> oldConPoints = con->splitConnectorPoints(pos2);
      con->hide();
      
      // The actual new connector
      Connector *new1 = newNode->createInputConnector(node);
      node->addOutputConnector(new1);
      new1->setRoutePoints(*pointList,usedManual);
      
      // The two connectors formed from the original one when split
      Connector *new2 = newNode->createInputConnector(conStartNode);
      conStartNode->addOutputConnector(new2);
      new2->setRoutePoints( *oldConPoints.at(0), usedManual );
      
      Connector *new3 = conEndNode->createInputConnector(newNode);
      newNode->addOutputConnector(new3);
      new3->setRoutePoints( *oldConPoints.at(1), usedManual );
      
      // Avoid flicker: tell them to update their draw lists now
      con->updateConnectorPoints(false);
      new1->updateDrawList();
      new2->updateDrawList();
      new3->updateDrawList();
      
      // Now it's safe to remove the connector...
      con->removeConnector();
      flushDeleteList();
      
      deleteNodeGroup(conStartNode);
      deleteNodeGroup(conEndNode);
      createNodeGroup(newNode)->init();
      
      return new1;
}


Generated by  Doxygen 1.6.0   Back to index