lazhen
2025-01-07 b3987122cbbc46c5c59d3173f37fca3170b6dc5a
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
Quintiq file version 2.0
#parent: #root
Method GenerateTree () id:Method_FormSupplyChainVisualization_GenerateTree
{
  #keys: '[132894.0.847789972]'
  Body:
  [*
    // Create SCVNodes from selected PISPIP in Product Planning Matrix
    // This is the entry point of nodes generation and drawing
    
    // First insert SCVConfiguration into the dataholder
    // the MacroPlan will never be null because there is a precon
    // to this method
    pispip := DataHolderDisplayPISPIP.Data();
    if( not isnull( pispip ) )
    { 
      scvConfig := shadow( MacroPlan.SCVConfiguration() );
    
      scvConfig.Period_MP( relset, pispip.Period_MP() )
      // rootNode represents the current pispip we are selecting
      rootNode := this.CreateSCVPISPIPNode( &scvConfig, pispip, true /*isroot*/ );
      
      // Start generating upstream and downstream nodes
      rootNode.IsDepthLimitMet( false );
      this.GenerateNodes( &scvConfig, pispip, rootNode, scvConfig.UpstreamDepthLimit(), true /*isupstream*/ );
      rootNode.IsDepthLimitMet( false );
      this.GenerateNodes( &scvConfig, pispip, rootNode, scvConfig.DownstreamDepthLimit(), false /*isupstream*/ );
      
      // Determine the X position of the root node
      rootNode.X( scvConfig.BorderOffsetX() + scvConfig.UpstreamDepth() * scvConfig.OffsetX() );
      this.PopulateXPosition( &scvConfig, rootNode );
      this.PopulateDisplaySequence( &scvConfig, true /*isupstream*/, rootNode );
      scvConfig.DisplaySequence( 0 );
      this.PopulateDisplaySequence( &scvConfig, false /*isupstream*/, rootNode );
      this.PopulateYPosition( &scvConfig, true /*isupstream*/ );
      this.PopulateYPosition( &scvConfig, false /*isupstream*/ );
      this.AdjustTrees( &scvConfig );
      this.PopulateEdgePositions( &scvConfig );
      
      scvConfig.Width( max( scvConfig, SCVNode, node, node.X() ) + scvConfig.BorderOffsetX() );
      scvConfig.Height( max( scvConfig, SCVNode, node, node.Y() ) + scvConfig.BorderOffsetY() );
      
      // CustomDrawSCV.EnsureVisible( rootNode.X(), rootNode.Y(), 'center', 'center' );
      DataHolderSCVConfig.Data( &scvConfig );
    }
    else
    {
      if( not isnull( DataHolderSCVConfig.Data() ) )
      {
        DataHolderSCVConfig.Data().Delete();
      }
    }
  *]
}