Esempio n. 1
0
        /*! \cond PRIVATE */

        GroupSet addGroupItems(CGBoundsGroup group, ref List<CGSpot> spots, ref float remainingLength, ref float currentDistance, bool calcLengthOnly = false)
        {

            if (group.ItemCount == 0)
                return null;

            CGBounds currentBounds;
            int itemID;
            int added = 0;

            float gapBefore = group.SpaceBefore.Next;
            float gapAfter = group.SpaceAfter.Next;
            float remain = remainingLength - gapBefore;
            GroupSet vGroup = null;
            GroupSet endItems = new GroupSet();

            float dist = currentDistance + gapBefore;



            if (calcLengthOnly)
            {
                vGroup = new GroupSet();
                vGroup.Group = group;
                vGroup.Length = gapBefore + gapAfter;

            }
            // Fixed Start Item(s)

            for (int i = 0; i < group.FirstRepeating; i++)
            {
                itemID = group.Items[i].Index;
                currentBounds = getItemBounds(itemID);
                if (currentBounds)
                {
                    remain -= currentBounds.Depth;
                    if (remain > 0)
                    {
                        if (calcLengthOnly)
                        {
                            vGroup.Length += currentBounds.Depth;
                            vGroup.Items.Add(itemID);
                            vGroup.Distances.Add(dist);
                        }
                        else
                            spots.Add(getSpot(itemID, ref group, ref currentBounds, dist, remainingLength));

                        dist += currentBounds.Depth;
                        added++;
                    }
                    else
                    {
                        if (group.KeepTogether && added > 0)
                        {
                            spots.RemoveRange(spots.Count - added, added);
                        }
                        break;
                    }
                }
            }
            if (remain > 0)
            {
                float endDist = 0;
                // Fixed End Item(s)
                for (int i = group.LastRepeating + 1; i < group.ItemCount; i++)
                {
                    itemID = group.Items[i].Index;
                    currentBounds = getItemBounds(itemID);
                    if (currentBounds)
                    {
                        remain -= currentBounds.Depth;
                        if (remain > 0)
                        {
                            endItems.Length += currentBounds.Depth;
                            endItems.Items.Add(itemID);
                            endItems.Distances.Add(endDist);
                            endDist += currentBounds.Depth;
                        }
                        else
                            break;
                    }
                }


                if (remain > 0)
                {
                    // Mid Items
                    int itemIdx;
                    for (int i = group.FirstRepeating; i <= group.LastRepeating; i++)
                    {
                        itemIdx = (group.RepeatingOrder == CurvyRepeatingOrderEnum.Row) ? i : group.getRandomItemINTERNAL();
                        itemID = group.Items[itemIdx].Index;

                        currentBounds = getItemBounds(itemID);
                        if (currentBounds)
                        {
                            remain -= currentBounds.Depth;
                            if (remain > 0)
                            {
                                if (calcLengthOnly)
                                {
                                    vGroup.Length += currentBounds.Depth;
                                    vGroup.Items.Add(itemID);
                                    vGroup.Distances.Add(dist);
                                }
                                else
                                    spots.Add(getSpot(itemID, ref group, ref currentBounds, dist, remainingLength));

                                dist += currentBounds.Depth;
                                added++;
                            }
                            else
                            {
                                if (group.KeepTogether && added > 0)
                                {
                                    spots.RemoveRange(spots.Count - added, added);
                                }
                                break;
                            }
                        }
                    }
                }

                if (remain > 0 || !group.KeepTogether)
                {
                    for (int e = 0; e < endItems.Items.Count; e++)
                    {
                        var b = getItemBounds(endItems.Items[e]);
                        spots.Add(getSpot(endItems.Items[e], ref group, ref b, dist + endItems.Distances[e], remainingLength));
                        dist += b.Depth;
                    }
                }
            }

            remainingLength = remain - gapAfter;
            currentDistance = dist + gapAfter;
            return vGroup;
        }
Esempio n. 2
0
        /*! \cond PRIVATE */

        GroupSet addGroupItems(CGBoundsGroup group, ref List <CGSpot> spots, ref float remainingLength, ref float currentDistance, bool calcLengthOnly = false)
        {
            if (group.ItemCount == 0)
            {
                return(null);
            }

            CGBounds currentBounds;
            int      itemID;
            int      added = 0;

            float    gapBefore = group.SpaceBefore.Next;
            float    gapAfter  = group.SpaceAfter.Next;
            float    remain    = remainingLength - gapBefore;
            GroupSet vGroup    = null;
            GroupSet endItems  = new GroupSet();

            float dist = currentDistance + gapBefore;



            if (calcLengthOnly)
            {
                vGroup        = new GroupSet();
                vGroup.Group  = group;
                vGroup.Length = gapBefore + gapAfter;
            }
            // Fixed Start Item(s)

            for (int i = 0; i < group.FirstRepeating; i++)
            {
                itemID        = group.Items[i].Index;
                currentBounds = getItemBounds(itemID);
                if (currentBounds)
                {
                    remain -= currentBounds.Depth;
                    if (remain > 0)
                    {
                        if (calcLengthOnly)
                        {
                            vGroup.Length += currentBounds.Depth;
                            vGroup.Items.Add(itemID);
                            vGroup.Distances.Add(dist);
                        }
                        else
                        {
                            spots.Add(getSpot(itemID, ref group, ref currentBounds, dist, remainingLength));
                        }

                        dist += currentBounds.Depth;
                        added++;
                    }
                    else
                    {
                        if (group.KeepTogether && added > 0)
                        {
                            spots.RemoveRange(spots.Count - added, added);
                        }
                        break;
                    }
                }
            }
            if (remain > 0)
            {
                float endDist = 0;
                // Fixed End Item(s)
                for (int i = group.LastRepeating + 1; i < group.ItemCount; i++)
                {
                    itemID        = group.Items[i].Index;
                    currentBounds = getItemBounds(itemID);
                    if (currentBounds)
                    {
                        remain -= currentBounds.Depth;
                        if (remain > 0)
                        {
                            endItems.Length += currentBounds.Depth;
                            endItems.Items.Add(itemID);
                            endItems.Distances.Add(endDist);
                            endDist += currentBounds.Depth;
                        }
                        else
                        {
                            break;
                        }
                    }
                }


                if (remain > 0)
                {
                    // Mid Items
                    int itemIdx;
                    for (int i = group.FirstRepeating; i <= group.LastRepeating; i++)
                    {
                        itemIdx = (group.RepeatingOrder == CurvyRepeatingOrderEnum.Row) ? i : group.getRandomItemINTERNAL();
                        itemID  = group.Items[itemIdx].Index;

                        currentBounds = getItemBounds(itemID);
                        if (currentBounds)
                        {
                            remain -= currentBounds.Depth;
                            if (remain > 0)
                            {
                                if (calcLengthOnly)
                                {
                                    vGroup.Length += currentBounds.Depth;
                                    vGroup.Items.Add(itemID);
                                    vGroup.Distances.Add(dist);
                                }
                                else
                                {
                                    spots.Add(getSpot(itemID, ref group, ref currentBounds, dist, remainingLength));
                                }

                                dist += currentBounds.Depth;
                                added++;
                            }
                            else
                            {
                                if (group.KeepTogether && added > 0)
                                {
                                    spots.RemoveRange(spots.Count - added, added);
                                }
                                break;
                            }
                        }
                    }
                }

                if (remain > 0 || !group.KeepTogether)
                {
                    for (int e = 0; e < endItems.Items.Count; e++)
                    {
                        var b = getItemBounds(endItems.Items[e]);
                        spots.Add(getSpot(endItems.Items[e], ref group, ref b, dist + endItems.Distances[e], remainingLength));
                        dist += b.Depth;
                    }
                }
            }

            remainingLength = remain - gapAfter;
            currentDistance = dist + gapAfter;
            return(vGroup);
        }