Quintiq file version 2.0
#parent: #root
Method PopulateEdgePositions (
  output owning shadow[SCVConfiguration] scvConfig
) id:Method_FormSupplyChainVisualization_PopulateEdgePositions
{
  #keys: '[134266.2.4972183]'
  Body:
  [*
    // Populate edge positions using node positions
    // Populate SCVEdge starting and target positions
    
    traverse( scvConfig, SCVNode.SCVEdge, edge )
    {
      node1 := select( scvConfig, SCVNode, node,
                       edge.DestinationKey() = node.Key().AsQUILL() );
    
      node2 := select( scvConfig, SCVNode, node,
                       edge.OriginKey() = node.Key().AsQUILL() );
      
      sourceNode := ifexpr( edge.IsUpstream(), node1, node2 );
      targetNode := ifexpr( edge.IsUpstream(), node2, node1 );
      
      adjustmentX := scvConfig.NodeSize();
      adjustmentY := floor( scvConfig.NodeSize() / 2 );
      
      edge.FromX( sourceNode.X() + adjustmentX );
      edge.FromY( sourceNode.Y() + adjustmentY );
      edge.ToX( targetNode.X() );
      edge.ToY( targetNode.Y() + adjustmentY );
      
      // Assign label to the edge
      quantity := 0.0;
      label := this.ReturnEdgeLabel( &scvConfig, sourceNode, targetNode, quantity );
    
      edge.Quantity( quantity );
      edge.Label( label );
    }
  *]
}
