Lai,Risheng
2023-11-02 30c02e0c981b16be0918483543f4b812956c45d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Quintiq file version 2.0
#parent: CustomDrawRC/CustomDrawDataLayerOp
Response OnDrawObject (
  Operation object
) id:Response_CustomDrawRC_CustomDrawDataLayerOp_OnDrawObject
{
  #keys: '[139394.0.1282162832]'
  CanBindMultiple: false
  DefinitionID: 'Responsedef_WebCustomDrawDataLayer_OnDrawObject'
  QuillAction
  {
    Body:
    [*
      // Draw operation
      imagesize := ifexpr( object.Unit().IconName() <> '',
                           minvalue( region.BoundingRect().Height(), region.BoundingRect().Width() ), 0 );
      
      //Initialize borders
      surface.Pen().Style( PenSpecification::StyleSolid() );
      surface.Pen().Width( 1 )
      surface.Pen().Color( ColorScheme.RoutingConfigurator_RoutingOutline() );  
      
      //Initialize filled colors
      //It is safe to use color scheme as the routing config is not user / scenario specific
      colorstart := ColorScheme.RoutingConfigurator_OperationFromColor();
      colorend := ColorScheme.RoutingConfigurator_OperationToColor();
      
      // Set color to black if operation is being disabled
      if( not object.IsEnabled() )
      {
        colorstart := ColorScheme.RoutingConfigurator_Disabled();
        colorend := ColorScheme.RoutingConfigurator_Disabled();
      }
      
      surface.Brush().LinearGradient( region.BoundingRect(), colorstart, colorend, 0.0 );
      surface.Fill( region.Shape() );
      
      surface.Image( region.BoundingRect().Left(), region.BoundingRect().Top(), imagesize, imagesize, object.Unit().IconName()  + '(32)'  );
      surface.Rect( region.BoundingRect().Left(), region.BoundingRect().Top(), 
                    region.BoundingRect().Width(), region.BoundingRect().Height(), ColorScheme.RoutingConfigurator_RoutingOutline() );                                
      
      
      //Draw 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() ); //doesnt work
      // Add pen width to push the text rightward more to avoid clipping with the border
      surface.TextZoom( imagesize + surface.Pen().Width(), 0, region.BoundingRect().Width() - imagesize , region.BoundingRect().Height(), text, textformat ); // Add offset for images
      
      //draw input output drop here!
      //guide to be drawn below the operation
      routing := guard( object.RoutingStep().Routing(), null( Routing ) );                                           
      
      if( not isnull( routing ) and not routing.HasInputOrOutput() )
      {
        surface.Pen().Style( PenSpecification::StyleDotted() );
        surface.Pen().Width( rcv.EdgeThickness() )
        surface.Pen().Color( ColorScheme.RoutingConfigurator_DropHereHelp() );  
        surface.Brush().Color( ColorScheme.RoutingConfigurator_DropHereHelp() ); // to paint the solid arrowhead
        
        surface.TextColor( ColorScheme.RoutingConfigurator_DropHereHelp() );
      
        lblx := region.BoundingRect().Left();
        lbly := region.BoundingRect().Height() + 20;
        
        midh := [Number]( region.BoundingRect().Height() / 2 );
        midw := [Number]( region.BoundingRect().Width() / 2 );
      
        line := GraphicalLine::LineTo( midw, lbly, midw, midh );
        line.ArrowToEnd( true ).ArrowPos( GraphicalLine::ArrowPosEnd() );
        surface.Draw( line );
        
        textformat.WrapWords();
        surface.TextZoom( lblx, lbly, region.BoundingRect().Width(), region.BoundingRect().Height(),
                          Translations::MP_Routing_DropHereIO(), textformat ); 
      }
    *]
    GroupServerCalls: false
  }
}