Exemplo n.º 1
0
        public void ClearRect()
        {
            distancePath.Reset();

            vehiclePath.Reset();
            pictureBox.Invalidate();
        }
Exemplo n.º 2
0
        private void Grafico_Reload(object sender, EventArgs e)
        {
            _Timer.Stop();

            //Dibuja los ejes
            _ejes.Reset();
            _ejes.AddLine(_pxMargen, _pxMargen, _pxMargen, this.Height - _pxMargen);
            _ejes.AddLine(_pxMargen, this.Height - _pxMargen, this.Width - _pxMargen, this.Height - _pxMargen);

            _valores.Reset();
            _valores.AddString(_MaxValueY.ToString(), System.Drawing.FontFamily.GenericSansSerif, (int)System.Drawing.FontStyle.Regular, (float)5, new System.Drawing.Point(0, _pxMargen), System.Drawing.StringFormat.GenericDefault);
            _valores.AddString(_MinValueY.ToString(), System.Drawing.FontFamily.GenericSansSerif, (int)System.Drawing.FontStyle.Regular, (float)5, new System.Drawing.Point(0, this.Height - _pxMargen), System.Drawing.StringFormat.GenericDefault);

            //Pepara la línea gráfica
            _Barras.Reset();
            Point[] _vertices = new Point[((this.Width - _pxMargen) / _pxAnchoTick) + 3];
            _vertices[0] = new Point(_pxMargen, this.Height - _pxMargen);
            _vertices[1] = _vertices[0];

            int lastX = _pxMargen;

            for (int i = 2; i < _vertices.Length - 2; i++)
            {
                lastX        = +_pxAnchoTick;
                _vertices[i] = new Point(lastX, this.Height - _pxMargen);
            }

            _vertices[_vertices.Length - 2] = new Point(this.Width, this.Height - _pxMargen);
            _vertices[_vertices.Length - 1] = _vertices[_vertices.Length - 2];

            _Timer.Start();
        }
Exemplo n.º 3
0
        private void pictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (startDrawing)
            {
                if (Control.ModifierKeys == Keys.Control)
                {
                    mousePath.Reset();
                    mousePath.AddLine(startPoint.X, startPoint.Y, startPoint.X, e.Y);
                    measureWidth = false;
                    //lblDistance.Text = roadWidth(rescalePoint(startPoint), rescalePoint(new Point(e.X, e.Y))).ToString("#0.00") + "m";
                    //lblDistance.Location = new Point(e.X + 5, e.Y - 14);

                    pictureBox.Invalidate();
                }
                else
                {
                    mousePath.Reset();
                    mousePath.AddLine(startPoint.X, startPoint.Y, e.X, startPoint.Y);
                    measureWidth = true;
                    //lblDistance.Text = roadWidth(rescalePoint(startPoint), rescalePoint(new Point(e.X, startPoint.Y))).ToString("#0.00") + "m";
                    //lblDistance.Location = new Point(e.X + 5, startPoint.Y - 14);

                    pictureBox.Invalidate();
                }
            }

            if (isZoomOn)
            {
                _main.activatePbZoom(e.X, e.Y, pictureBox.Image);
            }
        }
        private void makeRegionsFromHistGramEdges(List <Coord>[] coord_HistGramEdges, List <Region> regions)
        {
            for (int i = 0; i < coord_HistGramEdges.Length; i++)
            {
                List <Coord> coords = coord_HistGramEdges[i];
                System.Drawing.Drawing2D.GraphicsPath myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
                Region myRegion = new Region();
                myGraphicsPath.Reset();

                //添家多边形点
                Point[] Points = new Point[coords.Count];
                int     j      = 0;
                foreach (Coord coord in coords)
                {
                    Point p = new Point(coord.getX(), coord.getY());
                    Points[j] = p;
                    j++;
                }
                myGraphicsPath.AddPolygon(Points);
                myRegion.MakeEmpty();
                myRegion.Union(myGraphicsPath);
                //byte[] data = myRegion.GetRegionData().Data;
                //Console.WriteLine("myRegion.data.length " + data.Length);
                regions.Add(myRegion);
            }
        }
Exemplo n.º 5
0
            private System.Drawing.Drawing2D.GraphicsPath GetPath(int index)
            {
                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                path.Reset();

                Rectangle rect = this.GetTabRect(index);

                if (index == 0)
                {
                    path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2);
                    path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top);
                    path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                }
                else
                {
                    if (index == this.SelectedIndex)
                    {
                        path.AddLine(rect.Left + 5 - rect.Height, rect.Bottom + 1, rect.Left + 4, rect.Top + 2);
                        path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top);
                        path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                        path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left + 5 - rect.Height, rect.Bottom + 1);
                    }
                    else
                    {
                        path.AddLine(rect.Left, rect.Top + 6, rect.Left + 4, rect.Top + 2);
                        path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top);
                        path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                        path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left, rect.Bottom + 1);
                    }
                }
                return path;
            }
Exemplo n.º 6
0
 public bool contains(System.Drawing.Point p)
 {
     System.Drawing.Drawing2D.GraphicsPath myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
     //Region myRegion=new Region();
     myGraphicsPath.Reset();
     myGraphicsPath.AddPolygon(toPoints());
     return(myGraphicsPath.IsVisible(p));
 }
Exemplo n.º 7
0
 private void makeHole()
 {
     SuspendLayout();
     gpath.Reset();
     gpath.AddRectangle(new Rectangle(0, 0, this.Size.Width, this.Size.Height));
     gpath.AddRectangle(new Rectangle(6, 6, Size.Width - 12, this.Size.Height - 12));
     Region = new Region(gpath);
     ResumeLayout();
 }
Exemplo n.º 8
0
        /// <summary>
        /// Render plot view region of line chart component.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context.</param>
        protected override void OnPaint(DrawingContext dc)
        {
            var axisChart = base.Chart as AxisChart;

            if (axisChart == null)
            {
                return;
            }

            var ds = Chart.DataSource;

            var g          = dc.Graphics;
            var clientRect = this.ClientBounds;


            var path = new System.Drawing.Drawing2D.GraphicsPath();

            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style     = axisChart.DataSerialStyles[r];
                var lastPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[0], axisChart.ZeroHeight);

                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    var pt = axisChart.PlotDataPoints[r][c];

                    System.Drawing.PointF point;

                    if (pt.hasValue)
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight - pt.value);
                    }
                    else
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight);
                    }

                    path.AddLine(lastPoint, point);
                    lastPoint = point;
                }

                var endPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[ds.CategoryCount - 1], axisChart.ZeroHeight);

                if (lastPoint != endPoint)
                {
                    path.AddLine(lastPoint, endPoint);
                }

                path.CloseFigure();

                g.FillPath(style.FillColor, path);

                path.Reset();
            }

            path.Dispose();
        }
Exemplo n.º 9
0
        public void DrawRect(int[] data)
        {
            Debug.WriteLine(data);

            Point min = scaledPoint(new Point(data[0], data[1]));
            Point max = scaledPoint(new Point(data[2], data[3]));

            Debug.WriteLine(min);
            Debug.WriteLine(max);

            Rectangle rect = new Rectangle(min.X, min.Y, max.X - min.X, max.Y - min.Y);

            vehiclePath.Reset();
            vehiclePath.AddRectangle(rect);
            speedPath.AddString(data[4].ToString() + " kmh", System.Drawing.FontFamily.GenericSansSerif, 0, 18, new Point(min.X, min.Y - 18), StringFormat.GenericDefault);

            pictureBox.Invalidate();
        }
Exemplo n.º 10
0
        public void showHomography(Boolean showing)
        {
            if (showing)
            {
                homoPlane.Reset();
                homoPlane.StartFigure();

                homoPlane.AddLine(scaledPoint(_main.hPlane[0]), scaledPoint(_main.hPlane[1]));
                homoPlane.AddLine(scaledPoint(_main.hPlane[1]), scaledPoint(_main.hPlane[2]));
                homoPlane.AddLine(scaledPoint(_main.hPlane[2]), scaledPoint(_main.hPlane[3]));
                homoPlane.AddLine(scaledPoint(_main.hPlane[3]), scaledPoint(_main.hPlane[0]));

                pictureBox.Invalidate();
            }
            else
            {
                homoPlane.Reset();
                pictureBox.Invalidate();
            }
        }
Exemplo n.º 11
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            if (this.Height != this.Width)
            {
                this.Height = this.Width;
            }
            R = this.Width / 2.0;
            center_shift.Width = (Int32)R; center_shift.Height = (Int32)R;

            thispath.Reset();
            thispath.AddEllipse(new Rectangle(-1, -1, this.Width + 2, this.Height + 2));
            this.Region = new Region(thispath);

            base.OnLayout(levent);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Render plot view region of line chart component.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context.</param>
        protected override void OnPaint(DrawingContext dc)
        {
            var axisChart = Chart as AxisChart;

            var ai = axisChart.PrimaryAxisInfo;

            if (double.IsNaN(ai.Levels) || ai.Levels <= 0)
            {
                return;
            }

            var ds = Chart.DataSource;

            var g          = dc.Graphics;
            var clientRect = ClientBounds;

            double scaleX     = clientRect.Width / ds.CategoryCount;
            double scaleY     = clientRect.Height / (ai.Maximum - ai.Minimum);
            var    zeroHeight = (RGFloat)(ai.Minimum * scaleY + clientRect.Height);

#if WINFORM
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style     = axisChart.DataSerialStyles[r];
                var lastPoint = new System.Drawing.PointF((RGFloat)(0.5 * scaleX), zeroHeight);

                var point = lastPoint;
                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    if (ds[r][c] is double value)
                    {
                        point.Y = zeroHeight - (RGFloat)(value * scaleY);
                    }
                    else
                    {
                        point.Y = zeroHeight;
                    }
                    path.AddLine(lastPoint, point);
                    lastPoint = point;
                    point.X  += (RGFloat)scaleX;
                }

                if (lastPoint.Y != zeroHeight)
                {
                    point.X = lastPoint.X;
                    point.Y = zeroHeight;
                    path.AddLine(lastPoint, point);
                }

                path.CloseFigure();

                g.FillPath(style.FillColor, path);

                path.Reset();
            }

            path.Dispose();
#elif WPF
            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style = axisChart.DataSerialStyles[r];

                var seg = new System.Windows.Media.PathFigure();

                var lastPoint = new System.Windows.Point(0.5 * scaleX, zeroHeight);
                seg.StartPoint = lastPoint;

                var point = seg.StartPoint;
                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    if (ds[r][c] is double value)
                    {
                        point.Y = zeroHeight - value * scaleY;
                    }
                    else
                    {
                        point.Y = zeroHeight;
                    }
                    seg.Segments.Add(new System.Windows.Media.LineSegment(point, true));
                    lastPoint = point;
                    point.X  += scaleX;
                }

                point.X = lastPoint.X;
                point.Y = zeroHeight;
                seg.Segments.Add(new System.Windows.Media.LineSegment(point, true));

                seg.IsClosed = true;

                var path = new System.Windows.Media.PathGeometry();
                path.Figures.Add(seg);
                g.FillPath(style.LineColor, path);
            }
#endif // WPF
        }
Exemplo n.º 13
0
        public void AddSample(float progress, float value)
        {
            if (graph == null)
            {
                graph     = new Bitmap(this.Width - 2 * borderSize, this.Height - 2 * borderSize);
                marker    = new Bitmap(graph.Width, (int)(this.Font.GetHeight(graph.VerticalResolution) + 0.5f));
                drawIndex = -1;
                maxIndex  = (int)((graph.Width - 1) * 1f / PIXELS_PER_INDEX);
            }

            int   width = graph.Width;
            int   index = (int)((graph.Width - 1) * progress / PIXELS_PER_INDEX);
            int   count;
            float valueAvg;
            bool  redrawBounds = false;

            if (currentIndex == index)
            {
                currentAvg += value;
                currentAvgCount++;

                return;
            }
            else if (currentAvgCount > 0)
            {
                valueAvg = (float)(currentAvg / currentAvgCount);

                count = samples.Count;

                if (count == 0 && currentIndex != 0)
                {
                    samples.Add(new PointF(0, valueAvg));
                    count++;
                }

                samples.Add(new PointF(currentIndex, valueAvg));
                count++;

                if (valueAvg >= maxValue)
                {
                    maxValue     = valueAvg * 1.01f;
                    drawIndex    = -1;
                    redrawBounds = true;
                }
                if (valueAvg < minValue)
                {
                    minValue     = valueAvg * 0.99f;
                    drawIndex    = -1;
                    redrawBounds = true;
                }

                currentIndex    = index;
                currentAvg      = value;
                currentAvgCount = 1;
            }
            else
            {
                currentIndex    = index;
                currentAvg      = value;
                currentAvgCount = 1;

                return;
            }

            using (var g = Graphics.FromImage(graph))
            {
                int     height = graph.Height;
                float   range  = maxValue - minValue;
                int     i      = 0;
                Point[] lines;
                Point   startpoint, endpoint;

                if (drawIndex < 0)
                {
                    drawIndex = 0;
                }
                drawIndex    = 0;
                redrawBounds = true;

                lines = new Point[count - drawIndex + 1];

                //previous lines within the area that needs to be updated
                for (int j = drawIndex; j < count; j++)
                {
                    PointF s = samples[j];
                    lines[i++] = new Point(
                        (int)(s.X * PIXELS_PER_INDEX),
                        (int)(height * (1 - (s.Y - minValue) / range)));
                }

                //adding on the current point using the previous average value, unless it's the last point, then use the current average and move it to the end of the graph
                float currentValue;
                if (index == maxIndex)
                {
                    currentValue = (float)(currentAvg / currentAvgCount);
                    lines[i++]   = new Point(
                        width,
                        (int)(height * (1 - (currentValue - minValue) / range)));
                }
                else
                {
                    currentValue = valueAvg;
                    lines[i++]   = new Point(
                        (int)(index * PIXELS_PER_INDEX),
                        (int)(height * (1 - (currentValue - minValue) / range)));
                }

                startpoint = lines[0];
                endpoint   = lines[count - drawIndex];

                pathGraph.Reset();

                //lines path with added beginning and end
                pathGraph.AddLine(new Point(startpoint.X, height), startpoint);
                pathGraph.AddLines(lines);
                pathGraph.AddLine(endpoint, new Point(endpoint.X + 1, height));

                //clipping the area to prevent aliased paths from overlapping
                Rectangle clip;
                if (redrawBounds)
                {
                    clip = new Rectangle(0, 0, width, height);
                    g.SetClip(clip);
                    g.Clear(this.BackColor);

                    textUpper = string.Format(textFormat, range * 0.75 + minValue);
                    textLower = string.Format(textFormat, range * 0.25 + minValue);

                    SizeF size;
                    int   w, h;

                    size            = g.MeasureString(textLower, this.Font);
                    w               = (int)(size.Width + 0.5f);
                    h               = (int)(size.Height + 0.5f);
                    textBoundsLower = new Rectangle(width - 2 - w, (int)(height * 0.75f) - h / 2, w, h);

                    size            = g.MeasureString(textUpper, this.Font);
                    w               = (int)(size.Width + 0.5f);
                    h               = (int)(size.Height + 0.5f);
                    textBoundsUpper = new Rectangle(width - 2 - w, (int)(height * 0.25f) - h / 2, w, h);
                }
                else
                {
                    clip = new Rectangle(startpoint.X, 0, endpoint.X - startpoint.X + 1, height);
                    g.SetClip(clip);
                    g.Clear(this.BackColor);
                }

                #region draw clip background

                int x2 = clip.Right;

                if (x2 >= textBoundsLower.X && clip.X < textBoundsLower.Right)
                {
                    g.DrawString(textLower, this.Font, brushText, textBoundsLower.X, textBoundsLower.Y);
                }

                if (x2 >= textBoundsUpper.X && clip.X < textBoundsUpper.Right)
                {
                    g.DrawString(textUpper, this.Font, brushText, textBoundsUpper.X, textBoundsUpper.Y);
                }

                if (clip.X < textBoundsLower.X - 5)
                {
                    int y1 = textBoundsLower.Y + textBoundsLower.Height / 2;
                    g.DrawLine(penLine, 0, y1, textBoundsLower.X - 5, y1);
                    //if (x2 >= textBoundsLower.X - 5)
                    //    g.DrawLine(penLine, clip.X, y1, textBoundsLower.X - 5, y1);
                    //else
                    //    g.DrawLine(penLine, clip.X, y1, x2, y1);
                }

                if (clip.X < textBoundsUpper.X - 5)
                {
                    int y1 = textBoundsUpper.Y + textBoundsUpper.Height / 2;
                    g.DrawLine(penLine, 0, y1, textBoundsUpper.X - 5, y1);
                    //if (x2 >= textBoundsUpper.X - 5)
                    //    g.DrawLine(penLine, clip.X, y1, textBoundsUpper.X - 5, y1);
                    //else
                    //    g.DrawLine(penLine, clip.X, y1, x2, y1);
                }

                #endregion

                g.FillPath(brushGraph, pathGraph);

                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                pathGraph.Reset();

                if (drawIndex > 0)
                {
                    //add the previous point to create an accurate line
                    //this point is outside the clip and will not be drawn
                    PointF s        = samples[drawIndex - 1];
                    var    previous = new Point(
                        (int)(s.X * PIXELS_PER_INDEX),
                        (int)(height * (1 - (s.Y - minValue) / range)));
                    pathGraph.AddLine(previous, startpoint);
                }

                pathGraph.AddLines(lines);

                g.DrawPath(penGraph, pathGraph);

                //the next draw includes the previous point to overwrite the current value
                drawIndex = count - 1;

                this.Invalidate(new Rectangle(clip.X + borderSize, clip.Y + borderSize, clip.Width, clip.Height));

                //this.Invalidate(new Rectangle(lineLocation, new Size(width, 1)));
                //this.Invalidate(textBounds);

                //lineLocation = new Point(borderSize + 1, endpoint.Y);

                //text = string.Format("{0:0} MB/s", currentValue);
                //SizeF size1 = g.MeasureString(text, this.Font);
                //textBounds = new Rectangle(borderSize + width - (int)(size1.Width + 0.5f) - 1, endpoint.Y - (int)(size1.Height + 0.5f) / 2, (int)(size1.Width + 0.5f), (int)(size1.Height + 0.5f));
                //if (textBounds.Y < 1 + borderSize)
                //    textBounds.Y = 1 + borderSize;
                //else if (textBounds.Bottom > height + borderSize - 1)
                //    textBounds.Y = height - borderSize - 1 - textBounds.Height;

                //if (pathText == null)
                //    pathText = new System.Drawing.Drawing2D.GraphicsPath();
                //else
                //    pathText.Reset();

                //int st = (int)this.Font.Style;
                //float emSize = g.DpiY * this.Font.SizeInPoints / 72;
                //pathText.AddString(text, this.Font.FontFamily, st, emSize, textBounds.Location, StringFormat.GenericDefault);

                //this.Invalidate(new Rectangle(lineLocation, new Size(width, 1)));
                //this.Invalidate(textBounds);
            }
        }
Exemplo n.º 14
0
        //private static bool rectIntersectWithPolygon(RectangleF rect, Path path)
        //{
        //    System.Drawing.Drawing2D.GraphicsPath temp = new System.Drawing.Drawing2D.GraphicsPath();
        //    temp.Reset();
        //    List<PointF> points = default(List<PointF>);
        //    foreach(object i in path.content)
        //    {
        //        if(i is Node)
        //        {
        //            Node node = (Node)i;
        //            if(rect.Contains((float)node.lon, (float)node.lat))
        //                return true;
        //            points.Add(new PointF((float)node.lon, (float)node.lat));
        //        }
        //    }
        //    temp.AddPolygon(points.ToArray());
        //    Region myRegion = new Region();
        //    myRegion.MakeEmpty();
        //    myRegion.Union(temp);
        //    PointF tempPt = new PointF();
        //    tempPt.X = rect.X;
        //    tempPt.Y = rect.Y;
        //    if(pointInPolygon(tempPt, myRegion))
        //        return true;
        //    tempPt.X = rect.X + rect.Width;
        //    tempPt.Y = rect.Y;
        //    if(pointInPolygon(tempPt, myRegion))
        //        return true;
        //    tempPt.X = rect.X;
        //    tempPt.Y = rect.Y + rect.Height;
        //    if(pointInPolygon(tempPt, myRegion))
        //        return true;
        //    tempPt.X = rect.X + rect.Width;
        //    tempPt.Y = rect.Y + rect.Height;
        //    if(pointInPolygon(tempPt, myRegion))
        //        return true;
        //    return false;
        //}
        private static bool intersectPolygon(RectangleF rect, Path path)
        {
            System.Drawing.Drawing2D.GraphicsPath temp = new System.Drawing.Drawing2D.GraphicsPath();
            temp.Reset();

            //            List<PointF> points = default(List<PointF>);
            List<PointF> points = new List<PointF>();
            foreach (object i in path.content)
            {
                if (i is Node)
                {
                    Node node = (Node)i;

                    if (rect.Contains((float)node.lon, (float)node.lat))
                        return true;

                    points.Add(new PointF((float)node.lon, (float)node.lat));

                }
            }

            if (points.Count >= 3)
            {
                temp.AddPolygon(points.ToArray());
            }
            else if (points.Count == 2)
            {
                temp.AddLine(points[0], points[1]);
            }

            Region myRegion = new Region();
            myRegion.MakeEmpty();
            myRegion.Union(temp);

            PointF tempPt = new PointF();
            tempPt.X = rect.X;
            tempPt.Y = rect.Y;
            if (pointInPolygon(tempPt, myRegion))
                return true;

            tempPt.X = rect.X + rect.Width;
            tempPt.Y = rect.Y;
            if (pointInPolygon(tempPt, myRegion))
                return true;

            tempPt.X = rect.X;
            tempPt.Y = rect.Y + rect.Height;
            if (pointInPolygon(tempPt, myRegion))
                return true;

            tempPt.X = rect.X + rect.Width;
            tempPt.Y = rect.Y + rect.Height;
            if (pointInPolygon(tempPt, myRegion))
                return true;

            return false;
        }
Exemplo n.º 15
0
        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            Canvas2     = new Canvas(this, new Point(480, 640));
            Canvas2.Graphics.Clear(System.Drawing.Color.Transparent);

            var bgtexture = Content.Load <Texture2D>("Images/Loading");

            var pen = new System.Drawing.Pen(System.Drawing.Brushes.OrangeRed, 2)
                      .With(p => { p.DashPattern = new float[] { 2.0f, 2.0f }; });

            Canvas2.Graphics.DrawLine(pen, new System.Drawing.Point(120 - 80, 120), new System.Drawing.Point(120 + 80, 120));
            Canvas2.Graphics.DrawLine(pen, new System.Drawing.Point(120, 120 - 80), new System.Drawing.Point(120, 120 + 80));
            Canvas2.Save();

            var texture0 = Content.Load <Texture2D>("Images/Compas");

            image = Image(texture0, Color.White * 0.2f, Align.Center, new Vector2(480 / 2, 480 / 2), 0f, new Vector2(1f, 1f), Vector2.Zero);


            var texture = Content.Load <Texture2D>("Images/Wind");

            sp              = SpriteSheet(texture, Color.White * 0.6f, Align.Center, new Vector2(480 / 2, 480 / 2), 0.0f, 0.4f, new Vector2(texture.Width / 14 / 2, texture.Height / 2), 14)[13];
            panel           = Panel(bgtexture, Color.White * 0.5f, Align.Left | Align.Top, Vector2.Zero, Panel(texture0, Color.White * 0.3f, Align.Left | Align.Top, Vector2.Zero, Spacer(new Vector2(480 / 2, 480 / 2))));
            sp.UpdateEvent += Sp_UpdateEvent;

            Canvas1 = new Canvas(this, new Point(480, 270));
            //Canvas1.Graphics.Clear(System.Drawing.Color.FromArgb(255, 30, 16, 18));
            Canvas1.Graphics.Clear(System.Drawing.Color.Transparent);
            Canvas1.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            // XY Grid
            Canvas1.Graphics.DrawLine(new System.Drawing.Pen(System.Drawing.Brushes.White, 3), 20, 20, 20, 50 * 5 + 1);
            Canvas1.Graphics.DrawLine(new System.Drawing.Pen(System.Drawing.Brushes.White, 3), 20 - 1, 50 * 5, 460, 50 * 5);

            for (var i = 5; i < 50; i += 5)
            {
                Canvas1.Graphics.DrawLine(new System.Drawing.Pen(System.Drawing.Brushes.White, 1), 15, i * 5, 20, i * 5);
            }

            for (var i = 50; i <= 450; i += 30)
            {
                Canvas1.Graphics.DrawLine(new System.Drawing.Pen(System.Drawing.Brushes.White, 1), i, 50 * 5, i, 50 * 5 + 5);
            }

            var xs     = List(50, 80, 110, 140, 170, 200, 230, 270, 300);
            var ys     = List(8, 16, 32, 21, 19, 16, 25, 33, 15);
            var points = xs.Zip(ys, (x, y) => new System.Drawing.PointF(x, 50 * 5 - y * 5)).ToArray();

            // Curved Line
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddCurve(points);
            Canvas1.Graphics.DrawPath(new System.Drawing.Pen(System.Drawing.Brushes.IndianRed, 2), path);
            path.Reset();

            // Circle Points
            points.ForEach(p => path.AddEllipse(p.X - 6, p.Y - 6, 12, 12));
            Canvas1.Graphics.FillPath(new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 30, 16, 18)), path);
            Canvas1.Graphics.DrawPath(new System.Drawing.Pen(System.Drawing.Brushes.White, 2), path);
            path.Reset();

            points.ForEach(p => path.AddEllipse(p.X - 8, p.Y - 8, 16, 16));
            Canvas1.Graphics.DrawPath(new System.Drawing.Pen(new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 30, 16, 18)), 3), path);
            path.Reset();

            //points.ForEach(p => {
            //  path.AddString($"{p.Y / 10}°", System.Drawing.FontFamily.GenericSansSerif, 1, 15, new System.Drawing.PointF(p.X - 20, p.Y + 20), System.Drawing.StringFormat.GenericDefault);
            //});

            Canvas1.Graphics.DrawPath(new System.Drawing.Pen(System.Drawing.Brushes.Black, 1), path);

            Canvas1.Save();

            PreviousState.Init();
        }
Exemplo n.º 16
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     pictureBox.CreateGraphics().Clear(Color.White);
     mousePath.Reset();
 }
Exemplo n.º 17
0
 void drawQuadTex(Graphics g, Bitmap tex, PointF[] quad) {
     System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
     gp.AddPolygon(new PointF[] { quad[0], quad[1], quad[3] });
     g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
     g.DrawImage(tex, new PointF[] { quad[0], quad[1], quad[3] });
     gp.Reset();
     gp.AddPolygon(new PointF[] { quad[2], quad[3], quad[1] });
     g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
     tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
     g.DrawImage(tex, new PointF[] { quad[2], quad[3], quad[1] });
     tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
     gp.Dispose();
     g.ResetClip();
 }
Exemplo n.º 18
0
        private void Carte_Paint(object sender, PaintEventArgs e)
        {
            int   i;
            float w, h;
            //projet = ((Musliw.MusliW)(this.MdiParent)).projet;
            Graphics page = e.Graphics;

            //page.Clear(this.BackColor);

            w = this.Width;
            h = this.Height;

            Pen  stylo = new Pen(fen.stylo_couleur, fen.epaisseur);
            Font fonte = new Font(FontFamily.GenericSansSerif, 7, FontStyle.Bold);

            this.ForeColor = Color.Black;
            Brush brosse = new SolidBrush(fen.brosse_couleur);
            Brush brosse_texte = new SolidBrush(fen.couleur_texte);
            float dx = w / (projet.reseaux[nproj].xu - projet.reseaux[nproj].xl);
            float dy = h / (projet.reseaux[nproj].yu - projet.reseaux[nproj].yl);
            float deltax, deltay, voldeltax, voldeltay;
            float cx = 0.5f * (projet.reseaux[nproj].xu + projet.reseaux[nproj].xl);
            float cy = 0.5f * (projet.reseaux[nproj].yu + projet.reseaux[nproj].yl);

            //MessageBox.Show(xl.ToString() + " " + yu.ToString());
            PointF p1 = new PointF();
            PointF p2 = new PointF();
            PointF p3 = new PointF();
            PointF p4 = new PointF();
            PointF p5 = new PointF();


            PointF[] points = new PointF[4];
            float    angle = 0, norme = 0;
            float    sinx = 0, cosx = 1;

            if (fen.volume_echelle < 1e-6f)
            {
                fen.volume_echelle = 1e-6f;
            }
            for (i = 0; i < projet.reseaux[nproj].links.Count; i++)
            {
                norme = fen.norme(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
                if ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_visible == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_visible == true && norme > 0) && (projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_valid == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_valid == true))
                {
                    //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
                    //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
                    deltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
                    deltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
                    cosx   = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
                    sinx   = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);

                    voldeltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    voldeltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    page.DrawLine(stylo, ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay, ((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax, ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay, ((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax);


                    p1.X = ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay;
                    p1.Y = ((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax;
                    p2.X = ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + voldeltay;
                    p2.Y = ((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + voldeltax;
                    p3.X = ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + voldeltay;
                    p3.Y = ((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + voldeltax;
                    p4.X = ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay;
                    p4.Y = ((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax;


                    System.Drawing.Drawing2D.GraphicsPath epaisseur       = new System.Drawing.Drawing2D.GraphicsPath();
                    System.Drawing.Drawing2D.GraphicsPath texte_epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    epaisseur.StartFigure();
                    points[0] = p1;
                    points[1] = p2;
                    points[2] = p3;
                    points[3] = p4;


                    epaisseur.AddPolygon(points);
                    epaisseur.CloseFigure();
                    //page.FillPath(brosse, epaisseur);
                    //page.FillPolygon(brosse, points);
                    //page.DrawPolygon(stylo,points);
                    epaisseur.Reset();
                    texte_epaisseur.StartFigure();
                    p5.X = 0.5f * (p3.X + p2.X);
                    p5.Y = 0.5f * (p3.Y + p2.Y);
                    texte_epaisseur.AddString(projet.reseaux[projet.reseau_actif].links[i].volau.ToString("0"), FontFamily.GenericSansSerif, 0, fen.taille_texte, new PointF(p5.X, p5.Y), StringFormat.GenericDefault);
                    RectangleF encombrement = texte_epaisseur.GetBounds();
                    // texte_epaisseur.AddRectangle(encombrement);
                    //texte_epaisseur.AddPie(p5.X,p5.Y,2,2,0,360);

                    page.FillPolygon(brosse, points);
                    page.DrawPolygon(stylo, points);

                    if (encombrement.Width < fen.norme(p1.X, p4.X, p1.Y, p4.Y, 1) && projet.reseaux[projet.reseau_actif].links[i].volau > 0)
                    {
                        System.Drawing.Drawing2D.Matrix rotation = new System.Drawing.Drawing2D.Matrix();

                        if (cosx >= 0 && sinx <= 0)
                        {
                            angle = 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt(angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate(-0.5f * encombrement.Width * cosx, 0.5f * encombrement.Width * sinx);
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();
                            page.FillPath(brosse_texte, texte_epaisseur);
                        }
                        else if (cosx <= 0 && sinx >= 0)
                        {
                            angle = 180f - 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt(angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate(+0.5f * encombrement.Width * cosx + (encombrement.Height) * sinx, -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx);
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }
                        else if (cosx >= 0 && sinx >= 0)
                        {
                            angle = -180f * (float)Math.Acos(cosx) / (float)Math.PI;
                            rotation.RotateAt(angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate(-0.5f * encombrement.Width * cosx, 0.5f * encombrement.Width * sinx);
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }
                        else if (cosx <= 0 && sinx <= 0)
                        {
                            angle = 180 + 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt(angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate(+0.5f * encombrement.Width * cosx + (encombrement.Height) * sinx, -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx);
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }
                    }
                    epaisseur.Dispose();
                    texte_epaisseur.Dispose();
                }
            }

            /*        for (i = 0; i < projet.reseaux[nproj].nodes.Count; i++)
             *  {
             *      if (projet.reseaux[nproj].nodes[i].i != 0)
             *      {
             *          //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
             *          //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
             *          page.FillRectangle(brosse, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
             *          page.DrawRectangle(stylo, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
             *          page.DrawString(res.nodes[i].i.ToString(), fonte, Brushes.Black, new RectangleF((res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f));
             *      }
             *  }*/
        }
Exemplo n.º 19
0
        /// <summary>
        /// Render plot view region of line chart component.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context.</param>
        protected override void OnPaint(DrawingContext dc)
        {
            var axisChart = base.Chart as AxisChart;

            if (axisChart == null)
            {
                return;
            }

            var ds = Chart.DataSource;

            var g          = dc.Graphics;
            var clientRect = this.ClientBounds;


#if WINFORM
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style     = axisChart.DataSerialStyles[r];
                var lastPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[0], axisChart.ZeroHeight);

                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    var pt = axisChart.PlotDataPoints[r][c];

                    System.Drawing.PointF point;

                    if (pt.hasValue)
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight - pt.value);
                    }
                    else
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight);
                    }

                    path.AddLine(lastPoint, point);
                    lastPoint = point;
                }

                var endPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[ds.CategoryCount - 1], axisChart.ZeroHeight);

                if (lastPoint != endPoint)
                {
                    path.AddLine(lastPoint, endPoint);
                }

                path.CloseFigure();

                g.FillPath(style.FillColor, path);

                path.Reset();
            }

            path.Dispose();
#elif WPF
            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style = axisChart.DataSerialStyles[r];

                var seg = new System.Windows.Media.PathFigure();

                seg.StartPoint = new System.Windows.Point(axisChart.PlotColumnPoints[0], axisChart.ZeroHeight);

                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    var pt = axisChart.PlotDataPoints[r][c];

                    System.Windows.Point point;

                    if (pt.hasValue)
                    {
                        point = new System.Windows.Point(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight - pt.value);
                    }
                    else
                    {
                        point = new System.Windows.Point(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight);
                    }

                    seg.Segments.Add(new System.Windows.Media.LineSegment(point, true));
                }

                var endPoint = new System.Windows.Point(axisChart.PlotColumnPoints[ds.CategoryCount - 1], axisChart.ZeroHeight);
                seg.Segments.Add(new System.Windows.Media.LineSegment(endPoint, true));

                seg.IsClosed = true;

                var path = new System.Windows.Media.PathGeometry();
                path.Figures.Add(seg);
                g.FillPath(style.LineColor, path);
            }
#endif // WPF
        }
Exemplo n.º 20
0
 public void EndRead()
 {
     // fill after each glyph so overlapping text renders correctly.
     _graphics.FillPath(_brush, ps);
     ps.Reset();
 }
Exemplo n.º 21
0
		protected void PaintOneRange(int axisNumber, Graphics g, IPlotArea layer, IPlotRange range, Processed2DPlotData pdata)
		{
			const double logicalClampMinimum = -10;
			const double logicalClampMaximum = 11;

			_skipFrequency = Math.Max(1, _skipFrequency);

			// Plot error bars for the dependent variable (y)
			var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;
			var posErrCol = PositiveErrorColumn;
			var negErrCol = NegativeErrorColumn;

			if (null != posErrCol && !typeof(double).IsAssignableFrom(posErrCol.ItemType))
				posErrCol = null; // TODO make this an runtime paint error to be reported

			if (null != negErrCol && !typeof(double).IsAssignableFrom(negErrCol.ItemType))
				negErrCol = null; // TODO make this an runtime paint error to be reported

			if (posErrCol == null && negErrCol == null)
				return; // nothing to do if both error columns are null

			var strokePen = _pen.Clone();

			System.Drawing.Drawing2D.GraphicsPath errorBarPath = new System.Drawing.Drawing2D.GraphicsPath();

			Region oldClippingRegion = g.Clip;
			Region newClip = (Region)oldClippingRegion.Clone();


			int lower = range.LowerBound;
			int upper = range.UpperBound;

			for (int j = lower; j < upper; j += _skipFrequency)
			{
				int originalRowIndex = range.GetOriginalRowIndexFromPlotPointIndex(j);
				double symbolSize = null == _cachedSymbolSizeForIndexFunction ? _symbolSize : _cachedSymbolSizeForIndexFunction(originalRowIndex);
				strokePen.Width = (_lineWidth1Offset + _lineWidth1Factor * symbolSize);

				if (null != _cachedColorForIndexFunction)
					strokePen.Color = GdiColorHelper.ToNamedColor(_cachedColorForIndexFunction(originalRowIndex), "VariableColor");
				if (null != strokePen.EndCap)
					strokePen.EndCap = strokePen.EndCap.WithMinimumAbsoluteAndRelativeSize(symbolSize * _endCapSizeFactor + _endCapSizeOffset, 1 + 1E-6);

				AltaxoVariant vMeanPhysical = pdata.GetPhysical(axisNumber, originalRowIndex);
				Logical3D logicalMean = layer.GetLogical3D(pdata, originalRowIndex);
				logicalMean.RX += _cachedLogicalShiftX;
				logicalMean.RY += _cachedLogicalShiftY;

				if (!Calc.RMath.IsInIntervalCC(logicalMean.RX, logicalClampMinimum, logicalClampMaximum))
					continue;
				if (!Calc.RMath.IsInIntervalCC(logicalMean.RY, logicalClampMinimum, logicalClampMaximum))
					continue;

				var vMeanLogical = logicalMean.GetR(axisNumber);

				Logical3D logicalPos = logicalMean;
				Logical3D logicalNeg = logicalMean;
				bool logicalPosValid = false;
				bool logicalNegValid = false;

				switch (_meaningOfValues)
				{
					case ValueInterpretation.AbsoluteError:
						{
							if (posErrCol != null)
							{
								var vPosLogical = layer.Scales[axisNumber].PhysicalVariantToNormal(vMeanPhysical + Math.Abs(posErrCol[originalRowIndex]));
								vPosLogical = Calc.RMath.ClampToInterval(vPosLogical, logicalClampMinimum, logicalClampMaximum);
								logicalPos.SetR(axisNumber, vPosLogical);
								logicalPosValid = !logicalPos.IsNaN && vPosLogical != vMeanLogical;
							}

							if (negErrCol != null)
							{
								var vNegLogical = layer.Scales[axisNumber].PhysicalVariantToNormal(vMeanPhysical - Math.Abs(negErrCol[originalRowIndex]));
								vNegLogical = Calc.RMath.ClampToInterval(vNegLogical, logicalClampMinimum, logicalClampMaximum);
								logicalNeg.SetR(axisNumber, vNegLogical);
								logicalNegValid = !logicalNeg.IsNaN && vNegLogical != vMeanLogical;
							}
						}
						break;

					case ValueInterpretation.RelativeError:
						{
							if (posErrCol != null)
							{
								var vPosLogical = layer.Scales[axisNumber].PhysicalVariantToNormal(vMeanPhysical * (1 + Math.Abs(posErrCol[originalRowIndex])));
								vPosLogical = Calc.RMath.ClampToInterval(vPosLogical, logicalClampMinimum, logicalClampMaximum);
								logicalPos.SetR(axisNumber, vPosLogical);
								logicalPosValid = !logicalPos.IsNaN && vPosLogical != vMeanLogical;
							}

							if (negErrCol != null)
							{
								var vNegLogical = layer.Scales[axisNumber].PhysicalVariantToNormal(vMeanPhysical * (1 - Math.Abs(negErrCol[originalRowIndex])));
								vNegLogical = Calc.RMath.ClampToInterval(vNegLogical, logicalClampMinimum, logicalClampMaximum);
								logicalNeg.SetR(axisNumber, vNegLogical);
								logicalNegValid = !logicalNeg.IsNaN && vNegLogical != vMeanLogical;
							}
						}
						break;

					case ValueInterpretation.AbsoluteValue:
						{
							if (posErrCol != null)
							{
								var vPosLogical = layer.Scales[axisNumber].PhysicalVariantToNormal(posErrCol[originalRowIndex]);
								vPosLogical = Calc.RMath.ClampToInterval(vPosLogical, logicalClampMinimum, logicalClampMaximum);
								logicalPos.SetR(axisNumber, vPosLogical);
								logicalPosValid = !logicalPos.IsNaN && vPosLogical != vMeanLogical;
							}

							if (negErrCol != null)
							{
								var vNegLogical = layer.Scales[axisNumber].PhysicalVariantToNormal(negErrCol[originalRowIndex]);
								vNegLogical = Calc.RMath.ClampToInterval(vNegLogical, logicalClampMinimum, logicalClampMaximum);
								logicalNeg.SetR(axisNumber, vNegLogical);
								logicalNegValid = !logicalNeg.IsNaN && vNegLogical != vMeanLogical;
							}

							if (object.ReferenceEquals(negErrCol, posErrCol))
							{
								logicalNegValid = false; // then we need only to plot the positive column, since both colums are identical
							}
						}
						break;
				} // end switch

				if (!(logicalPosValid || logicalNegValid))
					continue; // nothing to do for this point if both pos and neg logical point are invalid.

				if (logicalNegValid)
				{
					errorBarPath.Reset();
					layer.CoordinateSystem.GetIsoline(errorBarPath, logicalMean, logicalNeg);
					PointF[] shortenedPathPoints = null;
					bool shortenedPathPointsCalculated = false;
					if (_useSymbolGap)
					{
						double gap = _symbolGapOffset + _symbolGapFactor * symbolSize;
						if (gap > 0)
						{
							errorBarPath.Flatten();
							var pathPoints = errorBarPath.PathPoints;
							shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(gap / 2), RADouble.NewAbs(0));
							shortenedPathPointsCalculated = true;
							if (null == shortenedPathPoints && _forceVisibilityOfEndCap && !(strokePen.EndCap is Altaxo.Graph.Gdi.LineCaps.FlatCap))
							{
								var totalLineLength = GdiExtensionMethods.TotalLineLength(pathPoints);
								var shortTheLineBy = Math.Max(0, totalLineLength - 0.125 * strokePen.Width);
								shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(shortTheLineBy), RADouble.NewAbs(0));
							}
						}
					}

					if (shortenedPathPointsCalculated)
					{
						if (null != shortenedPathPoints)
						{
							g.DrawLines(strokePen, shortenedPathPoints);
						}
					}
					else
					{
						g.DrawPath(strokePen, errorBarPath);
					}
				}

				if (logicalPosValid)
				{
					errorBarPath.Reset();
					layer.CoordinateSystem.GetIsoline(errorBarPath, logicalMean, logicalPos);
					PointF[] shortenedPathPoints = null;
					bool shortenedPathPointsCalculated = false;


					if (_useSymbolGap)
					{
						double gap = _symbolGapOffset + _symbolGapFactor * symbolSize;
						if (gap > 0)
						{
							errorBarPath.Flatten();
							var pathPoints = errorBarPath.PathPoints;
							shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(gap / 2), RADouble.NewAbs(0));
							shortenedPathPointsCalculated = true;
							if (null == shortenedPathPoints && _forceVisibilityOfEndCap && !(strokePen.EndCap is Altaxo.Graph.Gdi.LineCaps.FlatCap))
							{
								var totalLineLength = GdiExtensionMethods.TotalLineLength(pathPoints);
								var shortTheLineBy = Math.Max(0, totalLineLength - 0.125 * strokePen.Width);
								shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(shortTheLineBy), RADouble.NewAbs(0));
							}

						}
					}

					if (shortenedPathPointsCalculated)
					{
						if (null != shortenedPathPoints)
						{
							g.DrawLines(strokePen, shortenedPathPoints);
						}
					}
					else
					{
						g.DrawPath(strokePen, errorBarPath);
					}
				}
			}

			g.Clip = oldClippingRegion;

		}
Exemplo n.º 22
0
        protected void PaintXErrorBars(System.Drawing.Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata)
        {
            // Plot error bars for the independent variable (x)
            PlotRangeList rangeList = pdata.RangeList;

            PointF[]       ptArray   = pdata.PlotPointsInAbsoluteLayerCoordinates;
            INumericColumn posErrCol = _positiveErrorColumn.Document;
            INumericColumn negErrCol = _negativeErrorColumn.Document;

            if (posErrCol == null && negErrCol == null)
            {
                return; // nothing to do if both error columns are null
            }
            System.Drawing.Drawing2D.GraphicsPath errorBarPath = new System.Drawing.Drawing2D.GraphicsPath();

            Region oldClippingRegion = g.Clip;
            Region newClip           = (Region)oldClippingRegion.Clone();

            foreach (PlotRange r in rangeList)
            {
                int lower  = r.LowerBound;
                int upper  = r.UpperBound;
                int offset = r.OffsetToOriginal;
                for (int j = lower; j < upper; j++)
                {
                    AltaxoVariant x  = pdata.GetXPhysical(j + offset);
                    Logical3D     lm = layer.GetLogical3D(pdata, j + offset);
                    lm.RX += _cachedLogicalShiftOfIndependent;
                    if (lm.IsNaN)
                    {
                        continue;
                    }

                    Logical3D lh      = lm;
                    Logical3D ll      = lm;
                    bool      lhvalid = false;
                    bool      llvalid = false;
                    if (posErrCol != null)
                    {
                        lh.RX   = layer.XAxis.PhysicalVariantToNormal(x + Math.Abs(posErrCol[j + offset]));
                        lhvalid = !lh.IsNaN;
                    }
                    if (negErrCol != null)
                    {
                        ll.RX   = layer.XAxis.PhysicalVariantToNormal(x - Math.Abs(negErrCol[j + offset]));
                        llvalid = !ll.IsNaN;
                    }
                    if (!(lhvalid || llvalid))
                    {
                        continue; // nothing to do for this point if both pos and neg logical point are invalid.
                    }
                    // now paint the error bar
                    if (_symbolGap) // if symbol gap, then clip the painting, exclude a rectangle of size symbolSize x symbolSize
                    {
                        double xlm, ylm;
                        layer.CoordinateSystem.LogicalToLayerCoordinates(lm, out xlm, out ylm);
                        newClip.Union(oldClippingRegion);
                        newClip.Exclude(new RectangleF((float)(xlm - _symbolSize / 2), (float)(ylm - _symbolSize / 2), _symbolSize, _symbolSize));
                        g.Clip = newClip;
                    }

                    if (lhvalid && llvalid)
                    {
                        errorBarPath.Reset();
                        layer.CoordinateSystem.GetIsoline(errorBarPath, ll, lm);
                        layer.CoordinateSystem.GetIsoline(errorBarPath, lm, lh);
                        g.DrawPath(_strokePen, errorBarPath);
                    }
                    else if (llvalid)
                    {
                        layer.CoordinateSystem.DrawIsoline(g, _strokePen, ll, lm);
                    }
                    else if (lhvalid)
                    {
                        layer.CoordinateSystem.DrawIsoline(g, _strokePen, lm, lh);
                    }


                    // now the end bars
                    if (_showEndBars)
                    {
                        if (lhvalid)
                        {
                            PointF outDir;
                            layer.CoordinateSystem.GetNormalizedDirection(lm, lh, 1, new Logical3D(0, 1), out outDir);
                            outDir.X *= _symbolSize / 2;
                            outDir.Y *= _symbolSize / 2;
                            double xlay, ylay;
                            layer.CoordinateSystem.LogicalToLayerCoordinates(lh, out xlay, out ylay);
                            // Draw a line from x,y to
                            g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
                        }

                        if (llvalid)
                        {
                            PointF outDir;
                            layer.CoordinateSystem.GetNormalizedDirection(lm, ll, 1, new Logical3D(0, 1), out outDir);
                            outDir.X *= _symbolSize / 2;
                            outDir.Y *= _symbolSize / 2;
                            double xlay, ylay;
                            layer.CoordinateSystem.LogicalToLayerCoordinates(ll, out xlay, out ylay);
                            // Draw a line from x,y to
                            g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
                        }
                    }
                }
            }

            g.Clip = oldClippingRegion;
        }
Exemplo n.º 23
0
    protected void PaintXErrorBars(System.Drawing.Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata)
    {

      // Plot error bars for the independent variable (x)
      PlotRangeList rangeList = pdata.RangeList;
      PointF[] ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;
      INumericColumn posErrCol = _positiveErrorColumn.Document;
      INumericColumn negErrCol = _negativeErrorColumn.Document;

      if (posErrCol == null && negErrCol == null)
        return; // nothing to do if both error columns are null

      System.Drawing.Drawing2D.GraphicsPath errorBarPath = new System.Drawing.Drawing2D.GraphicsPath();

      Region oldClippingRegion = g.Clip;
      Region newClip = (Region)oldClippingRegion.Clone();

      foreach (PlotRange r in rangeList)
      {
        int lower = r.LowerBound;
        int upper = r.UpperBound;
        int offset = r.OffsetToOriginal;
        for (int j = lower; j < upper; j++)
        {
          AltaxoVariant x = pdata.GetXPhysical(j + offset);
          Logical3D lm = layer.GetLogical3D(pdata, j + offset);
          lm.RX += _cachedLogicalShiftOfIndependent;
          if (lm.IsNaN)
            continue;

          Logical3D lh = lm;
          Logical3D ll = lm;
          bool lhvalid = false;
          bool llvalid = false;
          if (posErrCol != null)
          {
            lh.RX = layer.XAxis.PhysicalVariantToNormal(x + Math.Abs(posErrCol[j + offset]));
            lhvalid = !lh.IsNaN;
          }
          if (negErrCol != null)
          {
            ll.RX = layer.XAxis.PhysicalVariantToNormal(x - Math.Abs(negErrCol[j + offset]));
            llvalid = !ll.IsNaN;
          }
          if (!(lhvalid || llvalid))
            continue; // nothing to do for this point if both pos and neg logical point are invalid.

          // now paint the error bar
          if (_symbolGap) // if symbol gap, then clip the painting, exclude a rectangle of size symbolSize x symbolSize
          {
            double xlm, ylm;
            layer.CoordinateSystem.LogicalToLayerCoordinates(lm, out xlm, out ylm);
            newClip.Union(oldClippingRegion);
            newClip.Exclude(new RectangleF((float)(xlm - _symbolSize / 2), (float)(ylm - _symbolSize / 2), _symbolSize, _symbolSize));
            g.Clip = newClip;
          }

          if (lhvalid && llvalid)
          {
            errorBarPath.Reset();
            layer.CoordinateSystem.GetIsoline(errorBarPath, ll, lm);
            layer.CoordinateSystem.GetIsoline(errorBarPath, lm, lh);
            g.DrawPath(_strokePen, errorBarPath);
          }
          else if (llvalid)
          {
            layer.CoordinateSystem.DrawIsoline(g, _strokePen, ll, lm);
          }
          else if (lhvalid)
          {
            layer.CoordinateSystem.DrawIsoline(g, _strokePen, lm, lh);
          }


          // now the end bars
          if (_showEndBars)
          {
            if (lhvalid)
            {
              PointF outDir;
              layer.CoordinateSystem.GetNormalizedDirection(lm, lh, 1, new Logical3D(0, 1), out outDir);
              outDir.X *= _symbolSize / 2;
              outDir.Y *= _symbolSize / 2;
              double xlay, ylay;
              layer.CoordinateSystem.LogicalToLayerCoordinates(lh, out xlay, out ylay);
              // Draw a line from x,y to 
              g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
            }

            if (llvalid)
            {
              PointF outDir;
              layer.CoordinateSystem.GetNormalizedDirection(lm, ll, 1, new Logical3D(0, 1), out outDir);
              outDir.X *= _symbolSize / 2;
              outDir.Y *= _symbolSize / 2;
              double xlay, ylay;
              layer.CoordinateSystem.LogicalToLayerCoordinates(ll, out xlay, out ylay);
              // Draw a line from x,y to 
              g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
            }

          }
        }
      }

      g.Clip = oldClippingRegion;
    }
Exemplo n.º 24
0
        private void Carte_Paint(object sender, PaintEventArgs e)
        {
            int i;
            double w, h;
            //projet = ((Musliw.MusliW)(this.MdiParent)).projet;
            Graphics page = e.Graphics;

            //page.Clear(this.BackColor);

            w = this.Width;
            h = this.Height;

            Pen stylo = new Pen(fen.stylo_couleur, (int)fen.epaisseur);
            Font fonte = new Font(FontFamily.GenericSansSerif, 7,FontStyle.Bold);
            this.ForeColor = Color.Black;
            Brush brosse =new SolidBrush(fen.brosse_couleur);
            Brush brosse_texte = new SolidBrush(fen.couleur_texte);
            double dx = w / (projet.reseaux[nproj].xu - projet.reseaux[nproj].xl);
            double dy = h / (projet.reseaux[nproj].yu - projet.reseaux[nproj].yl);
            double deltax,deltay,voldeltax,voldeltay;
            double cx = 0.5f * (projet.reseaux[nproj].xu + projet.reseaux[nproj].xl);
            double cy = 0.5f * (projet.reseaux[nproj].yu + projet.reseaux[nproj].yl);

            //MessageBox.Show(xl.ToString() + " " + yu.ToString());
            PointF p1=new PointF();
            PointF p2 = new PointF();
            PointF p3 = new PointF();
            PointF p4 = new PointF();
            PointF p5 = new PointF();

            PointF[] points = new PointF[4] ;
               double angle=0,norme=0;
            double sinx = 0, cosx = 1;
            if (fen.volume_echelle < 1e-6f)
            {
                fen.volume_echelle = 1e-6f;
            }
            for (i = 0; i < projet.reseaux[nproj].links.Count; i++)
            {
                norme = fen.norme(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
                if ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_visible == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_visible == true && norme > 0) && (projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_valid == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_valid == true))
                {

                    //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
                    //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
                deltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                deltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                cosx = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
                sinx = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);

                    voldeltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    voldeltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    page.DrawLine(stylo, (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay), (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax),(float) (((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay),(float) (((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax));

                    p1.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay);
                    p1.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax);
                    p2.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + voldeltay);
                    p2.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + voldeltax);
                    p3.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + voldeltay);
                    p3.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + voldeltax);
                    p4.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay);
                    p4.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax);

                    System.Drawing.Drawing2D.GraphicsPath epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    System.Drawing.Drawing2D.GraphicsPath texte_epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    epaisseur.StartFigure();
                    points[0] = p1;
                    points[1] = p2;
                    points[2] = p3;
                    points[3] = p4;

                    epaisseur.AddPolygon(points);
                    epaisseur.CloseFigure();
                    //page.FillPath(brosse, epaisseur);
                    //page.FillPolygon(brosse, points);
                    //page.DrawPolygon(stylo,points);
                    epaisseur.Reset();
                    texte_epaisseur.StartFigure();
                    p5.X = 0.5f * (p3.X + p2.X);
                    p5.Y = 0.5f * (p3.Y + p2.Y);
                    texte_epaisseur.AddString(projet.reseaux[projet.reseau_actif].links[i].volau.ToString("0"), FontFamily.GenericSansSerif, 0, (float)fen.taille_texte, new PointF(p5.X, p5.Y), StringFormat.GenericDefault);
                    RectangleF encombrement = texte_epaisseur.GetBounds();
                    // texte_epaisseur.AddRectangle(encombrement);
                    //texte_epaisseur.AddPie(p5.X,p5.Y,2,2,0,360);

                    page.FillPolygon(brosse, points);
                    page.DrawPolygon(stylo, points);

                    if (encombrement.Width < fen.norme(p1.X, p4.X, p1.Y, p4.Y, 1) && projet.reseaux[projet.reseau_actif].links[i].volau > 0)
                    {
                        System.Drawing.Drawing2D.Matrix rotation = new System.Drawing.Drawing2D.Matrix();

                        if (cosx >= 0 && sinx <= 0)
                        {
                            angle = 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();
                            page.FillPath(brosse_texte, texte_epaisseur);

                        }
                        else if (cosx <= 0 && sinx >= 0)
                        {
                            angle = 180f - 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(+0.5f * encombrement.Width * cosx + (encombrement.Height) * sinx),(float)( -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);

                        }
                        else if (cosx >= 0 && sinx >= 0)
                        {
                            angle = -180f * (float)Math.Acos(cosx) / (float)Math.PI;
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }
                        else if (cosx <= 0 && sinx <= 0)
                        {
                            angle = 180 + 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(+0.5f * encombrement.Width * cosx + (encombrement.Height) * sinx),(float)( -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }

                    }
                    epaisseur.Dispose();
                    texte_epaisseur.Dispose();
                }

            }
            /*        for (i = 0; i < projet.reseaux[nproj].nodes.Count; i++)
            {
                if (projet.reseaux[nproj].nodes[i].i != 0)
                {
                    //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
                    //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
                    page.FillRectangle(brosse, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
                    page.DrawRectangle(stylo, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
                    page.DrawString(res.nodes[i].i.ToString(), fonte, Brushes.Black, new RectangleF((res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f));
                }
            }*/
        }