Quintiq file version 2.0
#parent: CustomDrawComponentSupplyChainVisualization/CustomDrawDataLayerSCVEdge
Response OnDetermineRegion (
  shadow[SCVEdge] object
) id:Response_CustomDrawComponentSupplyChainVisualization_CustomDrawDataLayerSCVEdge_OnDetermineRegion
{
  #keys: '[132894.0.877947950]'
  Body:
  [*
    // Determine region for Edge
    scvconfig := DataHolderSCVConfiguration.Data();
    padding := 6;
    
    sourceNode := select( scvconfig, SCVNode, node,
                          object.DestinationKey() = node.Key().AsQUILL() );
    
    targetNode := select( scvconfig, SCVNode, node,
                          object.OriginKey() = node.Key().AsQUILL() );
    
    adjustmentX := scvconfig.NodeSize();
    adjustmentY := floor( scvconfig.NodeSize() / 2 );
    
    region := construct( Polygon );
    x0 := ifexpr( sourceNode.IsUpstream(), sourceNode.X(), targetNode.X() ) + adjustmentX;
    y0 := ifexpr( sourceNode.IsUpstream(), sourceNode.Y(), targetNode.Y() ) + adjustmentY;
    x1 := ifexpr( sourceNode.IsUpstream(), targetNode.X(), sourceNode.X() );
    y1 := ifexpr( sourceNode.IsUpstream(), targetNode.Y(), sourceNode.Y() ) + adjustmentY;
    
    // Adding points in a polygon must be in a clockwise manner
    region.AddPoint( x0, y0 + padding );
    region.AddPoint( x1, y1 + padding );
    region.AddPoint( x1, y1 - padding );
    region.AddPoint( x0, y0 - padding );
    
    this.AddRegion( region );
  *]
  CanBindMultiple: false
  DefinitionID: 'Responsedef_CustomDrawDataLayer_OnDetermineRegion'
}
