| 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(); | 
|       } | 
|     } | 
|   *] | 
| } |