Quintiq file version 2.0
|
#parent: #root
|
Function CalcX
|
{
|
TextBody:
|
[*
|
// Adhi Jan-30-2016 (created)
|
|
routingstep := this.RoutingStep();
|
rcv := this.RoutingConfiguratorView();
|
|
value := guard( routingstep.X(), 0 );
|
|
if( not isnull( routingstep ) and not isnull( rcv ) )
|
{
|
/*
|
To ensure centre alignment, we need to know the routing step with the highest number of operation
|
if this operation has the highest number of operation, then draw as usual.
|
Else, the logic will calculate the offset from x-position to make sure the operation are aligned in the centre
|
*/
|
routing := this.GetRouting();
|
rsmaxwidth := routing.MaxNrOfOperations();
|
rs := routingstep.Operation( relsize );
|
|
// If the routing step has the highest number of operation, draw like normal
|
if( rs = rsmaxwidth )
|
{
|
value := value + rcv.OperationOffsetX();
|
}
|
else
|
{
|
// Else, align to the centre
|
/*
|
If the number of operation within this routing is an even number
|
the middle part is offset
|
Else, the middle part is the middle point of the ((numberofoperation/2) + 1)th operation
|
*/
|
centeroffset := value
|
+ routingstep.Width() / 2;
|
|
if( rs mod 2 = 0 )
|
{
|
value := round( centeroffset
|
- rcv.OperationOffsetX() / 2
|
- ( rs / 2 ) * rcv.OperationWidth()
|
- ( ( rs / 2 ) - 1 ) * rcv.OperationOffsetX() );
|
}
|
else
|
{
|
value := round( centeroffset
|
- rcv.OperationWidth() / 2
|
- ( ( rs - 1 ) / 2 )* rcv.OperationWidth()
|
- ( ( rs - 1 ) / 2 ) * rcv.OperationOffsetX() );
|
}
|
}
|
|
// If previous operation exists, just check the last x position + offset + operation width
|
if( not isnull( this.Previous() ) )
|
{
|
value := this.Previous().X()
|
+ rcv.OperationOffsetX()
|
+ rcv.OperationWidth();
|
}
|
}
|
|
|
this.X( value );
|
*]
|
}
|