Пример #1
0
        private void RenderItemLabelsInternal(VisualPayload payload, int numLabels, float sizePeriod, float shiftRatio, bool discrete, List <ICriterionMetaSelector> criteria)
        {
            var startingOffset  = StartingOffset.GetLastKeyValue(payload.Data);
            var axisOrientation = AxisOrientation.GetLastKeyValue(payload.Data);

            var startX = startingOffset.x + (sizePeriod * shiftRatio * axisOrientation.x);
            var startY = startingOffset.y + (sizePeriod * shiftRatio * axisOrientation.y);
            var startZ = startingOffset.z + (sizePeriod * shiftRatio * axisOrientation.z);

            var localOffset    = new Vector3(startX, startY, startZ);
            var localOffsetAdd = new Vector3(sizePeriod * axisOrientation.x, sizePeriod * axisOrientation.y, sizePeriod * axisOrientation.z);

            var currentContinuousValue   = MinimumValue;
            var continuousValueIncrement = 0.0f;

            if (numLabels > 1)
            {
                continuousValueIncrement = (MaximumValue - MinimumValue) / (float)(numLabels - 1);
            }

            var maxSize = 0.0f;
            List <LabelBehaviour> labelsCreated = new List <LabelBehaviour>();



            for (var labelIndex = 0; labelIndex < numLabels; labelIndex++)
            {
                var    text     = String.Empty;
                object rowIndex = 0;

                if (discrete)
                {
                    var entries = AxisIndexVariable.GetEntries(payload.Data);

                    // Mind you, this is super inefficient.
                    foreach (var entry in entries)
                    {
                        if (labelIndex == AxisIndexVariable.GetValue(entry))
                        {
                            text     = ItemText.GetValue(entry);
                            rowIndex = AxisIndexVariable.GetValue(entry);
                            break;
                        }
                    }
                }
                else
                {
                    text     = currentContinuousValue.ToString("F2");
                    rowIndex = (float)currentContinuousValue;
                    currentContinuousValue += continuousValueIncrement;
                }

                var axisElementObj = LabelSystemFactory.InstantiateAxisElementLabel();

                var labelComponent = axisElementObj.GetComponent <AxisElementLabel>();

                LabelSystem.CreateLabel(text, localOffset, ItemLabelOrientation.GetLastKeyValue(payload.Data), labelComponent);

                labelComponent.SetCriteria(criteria, rowIndex);


                labelsCreated.Add(labelComponent);
                maxSize = Math.Max(maxSize, LabelSystem.GetDesiredLabelLength(labelComponent));

                localOffset += localOffsetAdd;
            }

            foreach (var label in labelsCreated)
            {
                LabelSystem.SetLabelLength(label, maxSize);
            }
        }