Пример #1
0
    public void ChangeGroup(PlanningGroup group)
    {
        this.group = group;
        UpdateLineCount(group.cells.Count);

        coords = group.center;
    }
Пример #2
0
    //
    // Public Methods
    //

    public void Init(PlanningGroup group, SummaryPanel summaryPanel)
    {
        base.Init(group.center, summaryPanel);

        this.group = group;
        UpdateLineCount(group.cells.Count);
    }
Пример #3
0
    private void AddOrUpdateGroupSmryLayerInfos(PlanningGroup group)
    {
        List <PlanningCell> cells = group.cells;

        foreach (PlanningCell cell in cells)
        {
            Typology typology = cell.typology;

            // Area occupied by each Typology in the group of cells
            if (typologyAreas.ContainsKey(typology))
            {
                typologyAreas[typology] += cell.areaSqM;
            }
            else
            {
                typologyAreas.Add(typology, cell.areaSqM);
            }
            group.groupPaintedArea += cell.areaSqM;

            // SummaryLayerInfo for each Typology in the group of cells
            if (summaryLayerInfos.ContainsKey(typology))
            {
                UpdateSummaryLayerInfo(typology, typologyAreas[typology]);
            }
            else
            {
                SummaryLayerInfo smryLayerInfo = NewSummaryLayerInfo(typology.color, typology.name, typologyAreas[typology]);
                summaryLayerInfos.Add(typology, smryLayerInfo);
            }
        }
    }
Пример #4
0
    public void UpdateGroupSummaryPanel(PlanningGroup group)
    {
        ClearTypologyCounts();
        ClearSummaryLayerInfos();
        ClearDistributionBars();

        AddOrUpdateGroupTypologyCounts(group);
        AddOrUpdateGroupSmryLayerInfos(group);
        AddOrUpdateGroupDistribBars(group);
    }
Пример #5
0
    private void AddOrUpdateGroupTypologyCounts(PlanningGroup group)
    {
        List <PlanningCell> cells = group.cells;

        foreach (PlanningCell cell in cells)
        {
            if (typologyCounts.ContainsKey(cell.typology))
            {
                ++typologyCounts[cell.typology];
            }
            else
            {
                typologyCounts.Add(cell.typology, 1);
            }
            ++totalTypologyCount;
        }
    }
Пример #6
0
    private void AddOrUpdateGroupDistribBars(PlanningGroup group)
    {
        List <PlanningCell> cells = group.cells;

        foreach (PlanningCell cell in cells)
        {
            Typology typology = cell.typology;
            if (distributionBars.ContainsKey(typology))
            {
                UpdateDistributionBar(typology);
            }
            else
            {
                DistributionBar dBar = NewDistribBar(typology.color, typologyCounts[typology] / (float)totalTypologyCount);
                distributionBars.Add(typology, dBar);
            }

            distributionContainer.gameObject.SetActive((distributionBars.Count > 1) ? true : false);
        }
    }
        protected override void ActivateView(string viewName, System.Collections.Generic.IDictionary <string, object> viewParameters)
        {
            try
            {
                IsNew = (bool)viewParameters["New"];
            }
            catch (KeyNotFoundException)
            {
            }

            var planningGroup = (PlanningGroup)viewParameters["PlanningGroup"];

            if (planningGroup != null)
            {
                PlanningGroup = planningGroup;
            }

            ReportControl = new ReportControlViewModel();
            if (planningGroup != null)
            {
                ReportControl.CurrentPlanningGroupId = planningGroup.PlanningGroupId;
            }
            ReportControl.LoadReportsForView((int)ReportViews.PlanningGroup, ReportService);
            RaisePropertyChanged(() => ReportControl);

            try
            {
                var profitCenterOrganization = (Organization)viewParameters["Organization"];
                if (profitCenterOrganization != null)
                {
                    CurrentProfitCenter = new ProfitCenter()
                    {
                        Name = profitCenterOrganization.Name,
                        ProfitCenterNumber = profitCenterOrganization.ExternalId
                    };
                }
            }
            catch (KeyNotFoundException)
            {
            }
        }
Пример #8
0
    private GroupPin AddGroupPin(PlanningGroup group)
    {
        // Create summary panel
        SummaryPanel groupSummary = Instantiate(summaryPanelPrefab, flagContainer, false);

        groupSummary.SetPlanningOutput(planningOutput);
        groupSummaries.Add(groupSummary);
        groupSummary.Init(summaryPanelPrefab.name, grid, 2);
        groupSummary.gameObject.SetActive(showFlags);

        // Create pin
        var groupPin = Instantiate(groupPinPrefab, pinContainer, true);

        groupPin.name = "Group_" + group.id;
        groupPin.Init(group, groupSummary);
        groupPin.globalCount = planningGroups.Count;
        groupPin.UpdatePosition(map);
        groupPins.Add(groupPin);

        return(groupPin);
    }
Пример #9
0
    private PlanningGroup CreateGroup(PlanningCell cell, int groupId)
    {
        PlanningGroup group = new PlanningGroup(groupId, this);

        group.center = new Coordinate();

        Queue <PlanningCell>   queue = new Queue <PlanningCell>();
        HashSet <PlanningCell> set   = new HashSet <PlanningCell>();

        queue.Enqueue(cell);
        set.Add(cell);

        int count = 0;

        while (queue.Count > 0)
        {
            cell = queue.Dequeue();
            int index = cell.x + cell.y * grid.countX;

            count++;
            group.cells.Add(cell);
            group.center.Longitude += cell.coords.Longitude;
            group.center.Latitude  += cell.coords.Latitude;
            cell.group              = groupId;

            if (cell.x > 0)
            {
                // Left
                AddNeighbor(index - 1, queue, set);

                // Top-Left
                if (cell.y > 0)
                {
                    AddNeighbor(index - 1 - grid.countX, queue, set);
                }

                // Bottom-Left
                if (cell.y < grid.countY - 1)
                {
                    AddNeighbor(index - 1 + grid.countX, queue, set);
                }
            }

            if (cell.x < grid.countX - 1)
            {
                // Right
                AddNeighbor(index + 1, queue, set);

                // Top-Right
                if (cell.y > 0)
                {
                    AddNeighbor(index + 1 - grid.countX, queue, set);
                }

                // Bottom-Right
                if (cell.y < grid.countY - 1)
                {
                    AddNeighbor(index + 1 + grid.countX, queue, set);
                }
            }

            // Top
            if (cell.y > 0)
            {
                AddNeighbor(index - grid.countX, queue, set);
            }

            // Bottom
            if (cell.y < grid.countY - 1)
            {
                AddNeighbor(index + grid.countX, queue, set);
            }
        }

        double invCount = 1.0 / count;

        group.center.Longitude *= invCount;
        group.center.Latitude  *= invCount;

        return(group);
    }
Пример #10
0
 private void UpdateGroupSummary(SummaryPanel groupSummary, PlanningGroup group)
 {
     groupSummary.gameObject.SetActive(showFlags);
     groupSummary.UpdateGroupSummaryPanel(group);
     groupSummary.gridNoData = group.gridNoData;
 }