hongji.li
2023-11-03 aefafd2142478d4fb07d6b8b45c3047e247389e0
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
Quintiq file version 2.0
#parent: #root
Function CalcY
{
  TextBody:
  [*
    // Adhi Jan-29-2016 (created)
    
    rcv := this.RoutingConfiguratorView();
    top := 0;
    inputgroupheight :=0;
    if( not isnull( rcv ) )
    {
      //default draw after 1 routngstep distance
     
     // if there is operationinputgroup, start in the middle of the last input group
      nrofinputinlastgroup := guard( this.LastOperationInputPISPNode().GroupSize(), 0 );
                                                
      nrofinput := this.OperationInputPISPNode( relsize );
      middleofinput := nrofinputinlastgroup / 2 + maxvalue( nrofinput - nrofinputinlastgroup, 0 );
      nrofgroup := counter( this, OperationInputPISPNode.OperationInput.OperationInputGroup, g, 
                            guard( g.First().IsLead(), false ) 
                            and not g.IsSystem() );
                            
      if ( middleofinput > 0 )
      { 
        inputgroupheight := [Number]( middleofinput * rcv.PISPHeight() + nrofgroup * rcv.OperationInputGroupThickness() * 2  ) ;
      }                                   
        
      prevstep := this.PreviousStep();
      if( not isnull( prevstep ) )
      {
        // routingstep y based on the maxvalue for previous step height, previous input and ouputput height
        previousoutputheight := guard( prevstep.LastOperationOutputPISPNode().PISPNodeY() + rcv.PISPHeight(), 0 );
        previousinputheight := guard( prevstep.LastOperationInputPISPNode().PISPNodeY() + rcv.PISPHeight(), 0 );
        top := maxvalue( prevstep.Y() + prevstep.Height(), previousinputheight, previousoutputheight ) + rcv.RoutingStepDistance(); 
      }
      else
      {
        // at least keep half of routing step distance for the first routing step
        inputgroupheight := maxvalue( rcv.OperationInputOutputHeight(), inputgroupheight ) + RoutingConfiguratorView::GetConstOffset();
      }
      top := top + inputgroupheight;
    
      this.Y( top );
    }
  *]
}