Пример #1
0
        public IVisio.Shape RenderPie(IVisio.Page page)
        {
            if (this.Angle == 0.0)
            {
                var p1 = this.GetPointAtRadius(this.Center, this.Radius, this.SectorStartAngle);
                return(page.DrawLine(this.Center, p1));
            }
            else if (this.Angle >= 2 * System.Math.PI)
            {
                var A     = this.Center.Add(-this.Radius, -this.Radius);
                var B     = this.Center.Add(this.Radius, this.Radius);
                var rect  = new Drawing.Rectangle(A, B);
                var shape = page.DrawOval(rect);
                return(shape);
            }
            else
            {
                int degree;
                var pie_bez = this.GetShapeBezierForPie(out degree);

                // Render the bezier
                var doubles_array = Drawing.Point.ToDoubles(pie_bez).ToArray();
                var pie_slice     = page.DrawBezier(doubles_array, (short)degree, 0);
                return(pie_slice);
            }
        }
Пример #2
0
        public IVisio.Shape RenderDoughnut(IVisio.Page page)
        {
            double total_angle = this.Angle;

            if (total_angle == 0.0)
            {
                var p1    = this.GetPointAtRadius(this.Center, this.SectorStartAngle, this.InnerRadius);
                var p2    = this.GetPointAtRadius(this.Center, this.SectorStartAngle, this.Radius);
                var shape = page.DrawLine(p1, p2);
                return(shape);
            }
            else if (total_angle >= System.Math.PI)
            {
                var outer_radius_point = new Drawing.Point(this.Radius, this.Radius);
                var C          = this.Center - outer_radius_point;
                var D          = this.Center + outer_radius_point;
                var outer_rect = new Drawing.Rectangle(C, D);

                var inner_radius_point = new Drawing.Point(this.InnerRadius, this.InnerRadius);
                var A          = this.Center - inner_radius_point - C;
                var B          = this.Center + inner_radius_point - C;
                var inner_rect = new Drawing.Rectangle(A, B);

                var shape = page.DrawOval(outer_rect);
                shape.DrawOval(inner_rect.Left, inner_rect.Bottom, inner_rect.Right, inner_rect.Top);

                return(shape);
            }
            else
            {
                int degree;
                var thickarc = this.GetShapeBezierForDoughnut(out degree);

                // Render the bezier
                var doubles_array = Drawing.Point.ToDoubles(thickarc).ToArray();
                var pie_slice     = page.DrawBezier(doubles_array, (short)degree, 0);
                return(pie_slice);
            }
        }
Пример #3
0
        public void Render(IVisio.Page page)
        {
            this.TotalMarginWidth = this.Rectangle.Width * (0.10);

            int    num_points  = this.DataPoints.Count;
            double bar_spacing = num_points > 1 ? (this.Rectangle.Width - this.TotalBarWidth) / num_points : 0.0;


            // Calculate min & max which will be used many times later
            double max   = this.DataPoints.Select(i => i.Value).Max();
            double min   = this.DataPoints.Select(i => i.Value).Min();
            var    range = ChartUtil.GetValueRangeDistance(min, max);

            // Determine the leftmost part of the drawing area
            double base_x = this.Rectangle.Left + (this.TotalMarginWidth / 2.0);

            // Determine the baseline height a.k.a the y axis location
            double base_y = this.Rectangle.Bottom;

            if (min < 0.0)
            {
                // if the min value is negative then we have to "raise" the baseline to accomodate it
                base_y += System.Math.Abs(this.Rectangle.Height * (min / range));
            }

            var category_axis_start_point = new Geometry.Point(this.Rectangle.Left, base_y);
            var category_axis_end_point   = new Geometry.Point(this.Rectangle.Right, base_y);
            var category_axis_shape       = page.DrawLine(category_axis_start_point, category_axis_end_point);

            double cur_x = base_x;

            var points = new List <Geometry.Point>();

            for (int i = 0; i < this.DataPoints.Count; i++)
            {
                if (i == 0)
                {
                    points.Add(new Geometry.Point(cur_x, base_y));
                }

                var p = this.DataPoints[i];

                var value_height = System.Math.Abs(this.Rectangle.Height * (p.Value / range));

                if (p.Value >= 0.0)
                {
                    points.Add(new Geometry.Point(cur_x, base_y + value_height));
                }
                else
                {
                    points.Add(new Geometry.Point(cur_x, base_y - value_height));
                }

                if (i == this.DataPoints.Count - 1)
                {
                    points.Add(new Geometry.Point(cur_x, base_y));
                }

                cur_x += bar_spacing;
            }

            points.Add(new Geometry.Point(base_x, base_y));


            var area_shape = page.DrawPolyline(points);


            var allshapes = this.DataPoints.Select(dp => dp.VisioShape).Where(s => s != null).ToList();

            allshapes.Add(category_axis_shape);

            ChartUtil.GroupShapesIfNeeded(page, allshapes);
        }
Пример #4
0
        public void Render(IVisio.Page page)
        {
            this.TotalMarginWidth     = this.Rectangle.Width * (0.10);
            this.TotalBarSpacingWidth = this.Rectangle.Width * (0.10);
            this.TotalBarWidth        = this.Rectangle.Width * (0.80);

            int num_points = this.DataPoints.Count;

            double bar_spacing = num_points > 1 ? this.TotalBarSpacingWidth / num_points : 0.0;
            double bar_width   = num_points > 0 ? this.TotalBarWidth / num_points : this.TotalBarWidth;

            double cur_x = this.Rectangle.Left + (this.TotalMarginWidth / 2.0);

            double max   = this.DataPoints.Select(i => i.Value).Max();
            double min   = this.DataPoints.Select(i => i.Value).Min();
            var    range = ChartUtil.GetValueRangeDistance(min, max);

            double base_y = this.Rectangle.Bottom;

            if (min < 0.0)
            {
                base_y += System.Math.Abs(this.Rectangle.Height * (min / range));
            }

            var category_axis_start_point = new Geometry.Point(this.Rectangle.Left, base_y);
            var category_axis_end_point   = new Geometry.Point(this.Rectangle.Right, base_y);
            var category_axis_shape       = page.DrawLine(category_axis_start_point, category_axis_end_point);

            foreach (var p in this.DataPoints)
            {
                var value_height = System.Math.Abs(this.Rectangle.Height * (p.Value / range));

                Geometry.Point bar_p0;
                Geometry.Point bar_p1;

                if (p.Value >= 0.0)
                {
                    bar_p0 = new Geometry.Point(cur_x, base_y);
                    bar_p1 = new Geometry.Point(cur_x + bar_width, base_y + value_height);
                }
                else
                {
                    bar_p0 = new Geometry.Point(cur_x, base_y - value_height);
                    bar_p1 = new Geometry.Point(cur_x + bar_width, base_y);
                }

                var bar_rect = new Geometry.Rectangle(bar_p0, bar_p1);
                var shape    = page.DrawRectangle(bar_rect);
                p.VisioShape = shape;

                if (p.Label != null)
                {
                    shape.Text = p.Label;
                }

                cur_x += bar_width + bar_spacing;
            }

            var allshapes = this.DataPoints.Select(dp => dp.VisioShape).Where(s => s != null).ToList();

            allshapes.Add(category_axis_shape);

            ChartUtil.GroupShapesIfNeeded(page, allshapes);
        }
Пример #5
0
        /// <summary>
        /// This method is drawing schema for single cable
        /// </summary>
        /// <param name="aPage">page to draw on</param>
        /// <param name="aCableInfo">information about cable to draw</param>
        /// <param name="aPosY">vertical position in which schema should start</param>
        /// <returns>ertical position after drawing</returns>
        private double DrawCable(Visio.Page aPage, CableInfo aCableInfo, double aPosY)
        {
            if (aCableInfo.CoreNo == 0)
            {
                aCableInfo.CoreInfo.Add(new CoreInfo(Database.DbElement.GetElement(), aCableInfo));
            }

            double _cableHeight = aCableInfo.CoreNo * mCoreHeight;

            Visio.Shape _newShape = aPage.DrawLine(mCablePosX, aPosY - _cableHeight / 2.0, mCablePosX + mCableWidth, aPosY - _cableHeight / 2.0);
            SetTextProperties(_newShape, aCableInfo.CableName + Environment.NewLine + aCableInfo.ComponentName, FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _newShape = aPage.DrawLine(mCablePosX, aPosY, mCablePosX, aPosY - _cableHeight);
            _newShape = aPage.DrawLine(mCablePosX + mCableWidth, aPosY, mCablePosX + mCableWidth, aPosY - _cableHeight);

            int    _lastBeginEqui = 0, _lastEndEqui = 0, _lastBeginElconn = 0, _lastEndElconn = 0, _current = 0;
            string _lastBeginEquiName = string.Empty, _lastEndEquiName = string.Empty, _lastBeginElconnName = string.Empty, _lastEndElconnName = string.Empty;

            foreach (CoreInfo _core in aCableInfo.CoreInfo)
            {
                //draw core boxes
                _newShape = aPage.DrawRectangle(mCablePosX - mCoreWidth - mSpaceBetween, aPosY - _current * mCoreHeight, mCablePosX - mSpaceBetween, aPosY - (_current + 1) * mCoreHeight);
                SetTextProperties(_newShape, _core.CoreName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                _newShape = aPage.DrawRectangle(mCablePosX + mCableWidth + mSpaceBetween, aPosY - _current * mCoreHeight, mCablePosX + mCableWidth + mSpaceBetween + mCoreWidth, aPosY - (_current + 1) * mCoreHeight);
                SetTextProperties(_newShape, _core.CoreName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

                //draw pin boxes
                _newShape = aPage.DrawRectangle(mCablePosX - (mCoreWidth + mSpaceBetween) * 2, aPosY - _current * mCoreHeight, mCablePosX - mCoreWidth - mSpaceBetween * 2, aPosY - (_current + 1) * mCoreHeight);
                SetTextProperties(_newShape, _core.StartPin, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                _newShape = aPage.DrawRectangle(mCablePosX + mCableWidth + mSpaceBetween * 2 + mCoreWidth, aPosY - _current * mCoreHeight, mCablePosX + mCableWidth + (mSpaceBetween + mCoreWidth) * 2, aPosY - (_current + 1) * mCoreHeight);
                SetTextProperties(_newShape, _core.EndPin, "6pt", (int)Visio.VisCellVals.visHorzCenter);

                //check/draw elconns
                if (_core.StartElconn == string.Empty || _lastBeginElconnName != _core.StartElconn)
                {
                    if (_current > 0)
                    {
                        double _posX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2;
                        double _posY = aPosY - _lastBeginElconn * mCoreHeight;
                        //draw elconn
                        _newShape = aPage.DrawRectangle(_posX - mElconnWidth, _posY, _posX, _posY - (_current - _lastBeginElconn) * mCoreHeight);
                        SetTextProperties(_newShape, _lastBeginElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                        _lastBeginElconn = _current;
                    }
                    _lastBeginElconnName = _core.StartElconn;
                }
                if (_core.EndElconn == string.Empty || _lastEndElconnName != _core.EndElconn)
                {
                    if (_current > 0)
                    {
                        //draw elconn
                        double _posX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth;
                        double _posY = aPosY - _lastEndElconn * mCoreHeight;
                        //draw elconn
                        _newShape = aPage.DrawRectangle(_posX, _posY, _posX + mElconnWidth, _posY - (_current - _lastEndElconn) * mCoreHeight);
                        SetTextProperties(_newShape, _lastEndElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                        _lastEndElconn = _current;
                    }
                    _lastEndElconnName = _core.EndElconn;
                }

                //check/draw equips
                if (_core.StartEqui == string.Empty || _lastBeginEquiName != _core.StartEqui)
                {
                    if (_current > 0)
                    {
                        //draw equi
                        double _posX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2 - mElconnWidth;
                        double _posY = aPosY - _lastBeginEqui * mCoreHeight;

                        _newShape = aPage.DrawRectangle(_posX - mEquiWidth, _posY, _posX, _posY - (_current - _lastBeginEqui) * mCoreHeight);
                        SetTextProperties(_newShape, _lastBeginEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                        _lastBeginEqui = _current;
                    }
                    _lastBeginEquiName = _core.StartEqui;
                }
                if (_core.EndEqui == string.Empty || _lastEndEquiName != _core.EndEqui)
                {
                    if (_current > 0)
                    {
                        //draw equi
                        double _posX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth + mElconnWidth;
                        double _posY = aPosY - _lastEndEqui * mCoreHeight;

                        _newShape = aPage.DrawRectangle(_posX, _posY, _posX + mEquiWidth, _posY - (_current - _lastEndEqui) * mCoreHeight);
                        SetTextProperties(_newShape, _lastEndEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                        _lastEndEqui = _current;
                    }
                    _lastEndEquiName = _core.EndEqui;
                }
                _current++;
            }
            //draw last elconns
            double _pX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2;
            double _pY = aPosY - _lastBeginElconn * mCoreHeight;

            _newShape = aPage.DrawRectangle(_pX - mElconnWidth, _pY, _pX, _pY - (_current - _lastBeginElconn) * mCoreHeight);
            SetTextProperties(_newShape, _lastBeginElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

            _pX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth;
            _pY = aPosY - _lastEndElconn * mCoreHeight;

            _newShape = aPage.DrawRectangle(_pX, _pY, _pX + mElconnWidth, _pY - (_current - _lastEndElconn) * mCoreHeight);
            SetTextProperties(_newShape, _lastEndElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

            //draw last equips
            _pX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2 - mElconnWidth;
            _pY = aPosY - _lastBeginEqui * mCoreHeight;

            _newShape = aPage.DrawRectangle(_pX - mEquiWidth, _pY, _pX, _pY - (_current - _lastBeginEqui) * mCoreHeight);
            SetTextProperties(_newShape, _lastBeginEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

            _pX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth + mElconnWidth;
            _pY = aPosY - _lastEndEqui * mCoreHeight;

            _newShape = aPage.DrawRectangle(_pX, _pY, _pX + mEquiWidth, _pY - (_current - _lastEndEqui) * mCoreHeight);
            SetTextProperties(_newShape, _lastEndEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

            return(aPosY - _cableHeight);
        }