Quintiq file version 2.0 
 | 
#parent: PanelSCV/CustomDrawDataLayerSCVEdge 
 | 
Response OnDrawObject ( 
 | 
  shadow[SCVEdge] object 
 | 
) id:Response_PanelSCV_CustomDrawDataLayerSCVEdge_OnDrawObject 
 | 
{ 
 | 
  #keys: '[134266.2.4973606]' 
 | 
  CanBindMultiple: false 
 | 
  DefinitionID: 'Responsedef_WebCustomDrawDataLayer_OnDrawObject' 
 | 
  QuillAction 
 | 
  { 
 | 
    Body: 
 | 
    [* 
 | 
      // Draw object 
 | 
      scvConfig := MacroPlan.SCVConfiguration(); 
 | 
       
 | 
      adjustmentX := scvConfig.NodeSize(); 
 | 
      adjustmentY := floor( scvConfig.NodeSize() / 2 ); 
 | 
       
 | 
      // Adjust line based on its orientations 
 | 
       
 | 
      topdown := object.ToY() > object.FromY(); 
 | 
      leftright := object.ToX() > object.FromX(); 
 | 
       
 | 
      padding := 6; 
 | 
       
 | 
       
 | 
      fromy := region.BoundingRect().Top() + padding; 
 | 
      toy := region.BoundingRect().Height() - padding; 
 | 
       
 | 
      if( topdown ) 
 | 
      { 
 | 
        if( not leftright ) 
 | 
        { 
 | 
          fromy := region.BoundingRect().Top() + padding; 
 | 
          toy := region.BoundingRect().Height() - padding; 
 | 
        } 
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        if( leftright ) 
 | 
        { 
 | 
          fromy := region.BoundingRect().Height() - padding; 
 | 
          toy := region.BoundingRect().Top() + padding; 
 | 
        } 
 | 
      } 
 | 
       
 | 
      // Get line quantity and label 
 | 
      quantity := object.Quantity(); 
 | 
      lineLabel := object.Label() 
 | 
       
 | 
      // Color the line gray if quantity is 0 or smaller 
 | 
      lineColor := ColorScheme.SupplyChainVisualization_Edge(); 
 | 
      if( quantity <= 0.0 ) 
 | 
      { 
 | 
        lineColor := ColorScheme.SupplyChainVisualization_Node(); 
 | 
        // Color the text gray too 
 | 
        surface.TextColor( lineColor ); 
 | 
      } 
 | 
       
 | 
      //Initialize drawing parameters 
 | 
      surface.Pen().Color( lineColor ) 
 | 
                   .Width( 1 ); 
 | 
      surface.Brush().Color( lineColor ); 
 | 
       
 | 
      // Draw the directional line 
 | 
      line := GraphicalLine::LineTo( region.BoundingRect().Left(), fromy, region.BoundingRect().Width(), toy ); 
 | 
      line.ArrowToEnd( true ).ArrowPos( GraphicalLine::ArrowPosMiddle() ); 
 | 
      surface.Draw( line ); 
 | 
       
 | 
      // Draw quantity label 
 | 
      // Get rotation angle to rotate the text to the same angle as the line 
 | 
      gradient := ( toy - fromy ) / ( region.BoundingRect().Width() - region.BoundingRect().Left() ); 
 | 
      degree := atan( -gradient ) * 180 / pi; 
 | 
      // Webclient doesn't support negative degree rotation 
 | 
       
 | 
      surface.Font().Name( scvConfig.FontName() ) 
 | 
                    .Size( scvConfig.FontSize() ) 
 | 
                    .Angle( [Number]degree ); 
 | 
       
 | 
      textformat := TextFormat::Construct( TextFormat::AlignCenter() ); 
 | 
       
 | 
      // Rotate the text to  
 | 
      if( object.FromY() = object.ToY() ) 
 | 
      { 
 | 
        surface.TextZoom( region.BoundingRect().Left(), region.BoundingRect().Top() - scvConfig.FontSize(), 
 | 
                          region.BoundingRect().Width(), scvConfig.FontSize() * 2, 
 | 
                          lineLabel, textformat ); 
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        // If targetnode and sourcenode have different Y positions, 
 | 
        // it means there is a gradient and we need to rotate the  
 | 
        // text. The hardcoded offsets below are the sweet numbers 
 | 
        // that we found that allows the text to have even distance to line 
 | 
        // for any angle of rotation 
 | 
        textformat := TextFormat::Construct( TextFormat::AlignCentered() ); 
 | 
        surface.TextZoom( region.BoundingRect().Left(), region.BoundingRect().Top() + ifexpr( gradient > 0, -14, -4 ), 
 | 
                          region.BoundingRect().Width(), region.BoundingRect().Height(), 
 | 
                          [String]lineLabel, textformat );     
 | 
      } 
 | 
    *] 
 | 
    GroupServerCalls: false 
 | 
  } 
 | 
} 
 |