lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
Quintiq file version 2.0
#parent: #root
Method CalculateToAndFrom () declarative
{
  Description: 'Set the to and from position of stocking point unit edge'
  TextBody:
  [*
    // Set the to and from position of stocking point unit edge
    // This is only used in GUI
    sp := this.StockingPointNode();
    unit := this.UnitNode();
    
    // Check if StockingPointNode and UnitNode is null
    if( not isnull( sp ) and not isnull( unit ) )
    {
      // Check if StockingPointNode's unit is at the same level as UnitNode's parent
      issamelevel := guard( sp.StockingPoint_MP().Unit() = unit.Unit().Parent(), true );
      // Check if this StockingPointUnit is acting as input, populate the from/to x/y accordingly
      if( this.StockingPointUnit().IsInput() )
      {
        belongstounit := select( sp, StockingPoint_MP.Unit.UnitNode, u, not issamelevel, u.ViewBase() = sp.ViewBase() )
        this.FromX( guard( belongstounit.X(), sp.X() ) );
        this.FromY( guard( belongstounit.Y(), sp.Y() ) );
    
        this.ToX( unit.X() );
        this.ToY( unit.Y() );
      }
      else
      {
        this.FromX( unit.X() );
        this.FromY( unit.Y() );
    
        belongstounit := select( sp, StockingPoint_MP.Unit.UnitNode, u, not issamelevel, u.ViewBase() = sp.ViewBase() )
        this.ToX( guard( belongstounit.X(), sp.X() ) );
        this.ToY( guard( belongstounit.Y(), sp.Y() ) );
      }
    }
  *]
}