Exemplo n.º 1
0
        public override void DrawGraph()
        {
            DrawBackground();

            var scale = Get2DBounds();

            var fullHeight = _location.height;
            var fullWidth  = _location.width;

            var heightMultiplier = fullHeight / scale.MaxY;

            var barWidth = fullWidth / _bars.Count;

            var xLoc = _location.xMin;

            var allKeys = _bars.SelectMany(b => b.Value.Keys).ToList();

            Dictionary <string, Vector2> previousCenters = null;

            foreach (var bar in _bars)
            {
                var centers = new Dictionary <string, Vector2>();
                var yLoc    = _location.yMax;
                foreach (var segment in bar.Value.OrderByDescending(seg => seg.Key))
                {
                    var barHeight = segment.Value * heightMultiplier;
                    yLoc -= barHeight;
                    Color colour   = GetColourForKey(segment.Key, allKeys);
                    var   position = new Rect(xLoc, yLoc, barWidth, barHeight);

                    var mouseover = position.Contains(Event.current?.mousePosition ?? Vector2.zero);
                    //var content = new GUIContent(segment.Key) { tooltip = segment.Key };
                    //GUI.Button(position, content);
                    GUI.DrawTexture(position, _pointTexture, ScaleMode.StretchToFill, true, 0.5f, colour, 0, 0);

                    var currentCenter = new Vector2(xLoc + (barWidth / 2), yLoc + (barHeight / 2));
                    centers[segment.Key] = currentCenter;

                    if (mouseover)
                    {
                        var mouseoverText = string.IsNullOrEmpty(segment.Key) ? "<No Modules>" : segment.Key;
                        GUI.Box(new Rect(_location.xMax + 20, currentCenter.y, _mouseoverSize.x, _mouseoverSize.y), mouseoverText);
                    }

                    if (previousCenters != null && previousCenters.ContainsKey(segment.Key))
                    {
                        var previousCenter = previousCenters[segment.Key];
                        GraphUtils.DrawLineBetweenPoints(previousCenter, currentCenter, _lineTexture, colour);
                    }
                }
                previousCenters = centers;
                xLoc           += barWidth;
            }
        }
Exemplo n.º 2
0
        internal void DrawPoints(Bounds2D scale, Rect location)
        {
            GraphPoint previous = null;

            foreach (var point in Points)
            {
                point.DrawPoint(scale, location, _pointTexture, _pointSize, Colour);
                if (previous != null)
                {
                    GraphUtils.DrawLineBetweenPoints(previous.ToUiPoint(scale, location), point.ToUiPoint(scale, location), _lineTexture, Colour, 3);
                }
                previous = point;
            }
        }