Quintiq file version 2.0
#parent: CustomDrawRC/CustomDrawDataLayerOutputPISPNodeInRouting
Response OnDrawObject (
  OperationOutputPISPNode object
) id:Response_CustomDrawRC_CustomDrawDataLayerOutputPISPNodeInRouting_OnDrawObject
{
  #keys: '[139394.0.1306665201]'
  CanBindMultiple: false
  DefinitionID: 'Responsedef_WebCustomDrawDataLayer_OnDrawObject'
  Precondition:
  [*
    return not isnull( object.OperationOutput().PISPOperationOutputEdge() )
  *]
  QuillAction
  {
    Body:
    [*
      // Draw PISP node in routing
      productimage := guard( select( object.OperationOutput().ProductInStockingPoint_MP().Product_MP(), ProductNode, pn, pn.IconName() <> '', true ).IconName(), '' );
      imagesize := minvalue ( region.BoundingRect().Height(), region.BoundingRect().Width() );
      
      //Initialize borders
      surface.Pen().Style( PenSpecification::StyleSolid() );
      surface.Pen().Width( 1 )
      surface.Pen().Color( ColorScheme.RoutingConfigurator_RoutingOutline() );
      
      colorstart := ColorScheme.RoutingConfigurator_PISPNodeInRoutingFromColor();
      colorend := ColorScheme.RoutingConfigurator_PISPNodeInRoutingToColor();
      
      if( object.OperationOutput().IsFloating() )
      {
        colorstart := ColorScheme.RoutingConfigurator_FloatingProduct();
        colorend := ColorScheme.RoutingConfigurator_FloatingProduct();
      }
      
      surface.Brush().LinearGradient( region.BoundingRect(), colorstart, colorend, 0.0 )
      surface.Fill( region.Shape() );
      
      
      //Initialize text
      rcv := MacroPlan.RoutingConfiguratorView();
      surface.Font().Name( rcv.FontName() );
      surface.Font().Size( rcv.FontSize() );
      surface.TextColor( Color::Black() );
      textformat := TextFormat::Construct( TextFormat::AlignLeft(), TextFormat::AlignMiddle() );
      
      if ( text = '' )
      {  
        if(  object.PISPNodeInRouting().IsFloating() )
        {
          text := object.PISPNodeInRouting().ProductInStockingPoint_MP().Product_MP().Name() + ' ' + Translations::MP_SanityCheck_MissingStockingPoint();
        }
        else
        {  
          text := object.OperationOutput().ProductInStockingPoint_MP().Name();
        }
      }
      
      if( productimage <> '' )
      {
        surface.Image( region.BoundingRect().Left(), region.BoundingRect().Top(), imagesize, imagesize, productimage + '(32)' );
        surface.TextZoom( region.BoundingRect().Left() + imagesize , region.BoundingRect().Top(), 
                          region.BoundingRect().Width() - imagesize , region.BoundingRect().Height(), text, textformat);
      }
      else
      {
        // Add pen width to push the text rightward more to avoid clipping with the border
        surface.TextZoom( region.BoundingRect().Left() + surface.Pen().Width(), region.BoundingRect().Top(),
                          region.BoundingRect().Width(), region.BoundingRect().Height(), 
                          text, textformat );
      }
      
      surface.Rect( region.BoundingRect().Left(), region.BoundingRect().Top(), 
                    region.BoundingRect().Width(), region.BoundingRect().Height(), ColorScheme.RoutingConfigurator_RoutingOutline() );
    *]
    GroupServerCalls: false
  }
}
