Esempio n. 1
0
        public override void Draw(Graphics gr, float schaal, RectangleF window)
        {
            if ((richtpunt == null) | (eindpunt == null) | (richtlijn == null))
            {
                return;
            }

            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First()).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M    = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);
            PointF Mtek = new PointF(M.X - window.Left, M.Y - window.Top);

            Mtek = new PointF(Mtek.X * schaal * 10, Mtek.Y * schaal * 10);

            // stap 4: bepalen van ligging EP
            //	- AP invullen in l
            bool teken_AP = a_l * AP.X + b_l * AP.Y + c_l > 0;
            //	- EP invullen in l
            bool teken_EP     = a_l * EP.X + b_l * EP.Y + c_l > 0;
            bool meer_dan_180 = !(teken_AP ^ teken_EP);

            // stap 5: hoeken
            float start = (float)(Math.Atan2(RP.Y - M.Y, RP.X - M.X) * 180 / Math.PI);
            float end   = (float)(Math.Atan2(EP.Y - M.Y, EP.X - M.X) * 180 / Math.PI);
            float sweep = end - start;

            if (meer_dan_180 & (-180 < sweep) & (sweep < 180))
            {
                sweep += sweep < 0 ? 360 : -360;
            }
            if (!meer_dan_180 & ((sweep < -180) | (180 < sweep)))
            {
                sweep += sweep < 0 ? 360 : -360;
            }

            double R_tek = Ellips.Pyt(M, RP) * schaal * 10;

            Pen pen = (Pen)GetPen(true).Clone();

            pen.Width = pen.Width / 2.54f;
            gr.DrawArc(pen, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
        }
Esempio n. 2
0
        public override Region GetRegion(Tekening tek)
        {
            if ((richtpunt == null) | (eindpunt == null) | (richtlijn == null))
            {
                return(new Region());
            }
            Graphics gr = tek.CreateGraphics();

            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)(richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First())).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M    = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);
            PointF Mtek = tek.co_pt(M, gr.DpiX, gr.DpiY);

            // stap 4: bepalen van ligging EP
            //	- AP invullen in l
            bool teken_AP = a_l * AP.X + b_l * AP.Y + c_l > 0;
            //	- EP invullen in l
            bool teken_EP     = a_l * EP.X + b_l * EP.Y + c_l > 0;
            bool meer_dan_180 = !(teken_AP ^ teken_EP);

            // stap 5: hoeken
            float start = (float)(Math.Atan2(RP.Y - M.Y, RP.X - M.X) * 180 / Math.PI);
            float end   = (float)(Math.Atan2(EP.Y - M.Y, EP.X - M.X) * 180 / Math.PI);
            float sweep = end - start;

            if (meer_dan_180 & (-180 < sweep) & (sweep < 180))
            {
                sweep += sweep < 0 ? 360 : -360;
            }
            if (!meer_dan_180 & ((sweep < -180) | (180 < sweep)))
            {
                sweep += sweep < 0 ? 360 : -360;
            }

            double R_tek = Ellips.Pyt(M, RP) * tek.Schaal * gr.DpiX / 2.54f;

            GraphicsPath path = new GraphicsPath();

            path.AddArc((float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
            return(new Region(path));
        }
Esempio n. 3
0
        public override RectangleF Bounds(Graphics gr)
        {
            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First()).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);

            float R = (float)Ellips.Pyt(M, RP);

            return(new RectangleF(M.X - R, M.Y - R, 2 * R, 2 * R));
        }
Esempio n. 4
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if ((richtpunt == null) | (eindpunt == null) | (richtlijn == null))
            {
                return;
            }

            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)(richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First())).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M    = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);
            PointF Mtek = tek.co_pt(M, gr.DpiX, gr.DpiY);

            // stap 4: bepalen van ligging EP
            //	- AP invullen in l
            bool teken_AP = a_l * AP.X + b_l * AP.Y + c_l > 0;
            //	- EP invullen in l
            bool teken_EP     = a_l * EP.X + b_l * EP.Y + c_l > 0;
            bool meer_dan_180 = !(teken_AP ^ teken_EP);

            // stap 5: hoeken
            float start = (float)(Math.Atan2(RP.Y - M.Y, RP.X - M.X) * 180 / Math.PI);
            float end   = (float)(Math.Atan2(EP.Y - M.Y, EP.X - M.X) * 180 / Math.PI);
            float sweep = end - start;

            if (meer_dan_180 & (-180 < sweep) & (sweep < 180))
            {
                sweep += sweep < 0 ? 360 : -360;
            }
            if (!meer_dan_180 & ((sweep < -180) | (180 < sweep)))
            {
                sweep += sweep < 0 ? 360 : -360;
            }

            double R_tek = Ellips.Pyt(M, RP) * tek.Schaal * gr.DpiX / 2.54f;


            Pen pen = (Pen)GetPen(false).Clone();

            if (Geselecteerd)
            {
                Pen selectie = new Pen(Color.Black, pen.Width + 2);
                pen.Width += 1;


                gr.DrawArc(selectie, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
                gr.DrawArc(pen, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
            }
            else
            {
                if (widepen)
                {
                    pen.Width    += 2;
                    pen.DashStyle = DashStyle.Solid;
                }
                gr.DrawArc(pen, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
            }
        }
Esempio n. 5
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if ((punt1 == null) | (punt2 == null))
            {
                return;
            }
            PointF p1 = tek.co_pt(punt1.Coordinaat, gr.DpiX, gr.DpiY);
            PointF p2 = tek.co_pt(punt2.Coordinaat, gr.DpiX, gr.DpiY);

            double alfa = Math.Atan2(punt1.Coordinaat.Y - punt2.Coordinaat.Y, punt1.Coordinaat.X - punt2.Coordinaat.X);
            double beta = alfa + Math.PI / 2;

            double dx = offset * tek.Schaal * Math.Cos(beta);
            double dy = offset * tek.Schaal * Math.Sin(beta);
            double sx = 5 * Math.Cos(beta);
            double sy = 5 * Math.Sin(beta);

            double t = 3 + 2 * LijnDikte;

            Pen pen  = (Pen)GetPen(false).Clone();                              // hoofdlijn
            Pen pen1 = new Pen(Geselecteerd ? Color.White : Color.Black, 1);    // hulplijnen

            double dbl_l = Ellips.Pyt(punt1.Coordinaat, punt2.Coordinaat);
            string l     = dbl_l.ToString("0.000");
            int    i     = ((dbl_l * tek.Schaal / 2.54f * gr.DpiX) < 50) ? -1 : 1;

            if (Geselecteerd)
            {
                Pen selectie  = new Pen(Color.Black, pen.Width + 2);
                Pen selectie1 = new Pen(Color.Black, 3);
                pen.Width += 1; pen1.Width += 1;

                gr.DrawLine(selectie1, p1, new PointF((float)(p1.X + dx + sx), (float)(p1.Y + dy + sy)));
                gr.DrawLine(selectie, new PointF((float)(p1.X + dx), (float)(p1.Y + dy)), new PointF((float)(p2.X + dx), (float)(p2.Y + dy)));
                gr.DrawLine(selectie1, p2, new PointF((float)(p2.X + dx + sx), (float)(p2.Y + dy + sy)));

                gr.DrawLine(pen1, p1, new PointF((float)(p1.X + dx + sx), (float)(p1.Y + dy + sy)));
                gr.DrawLine(pen, new PointF((float)(p1.X + dx), (float)(p1.Y + dy)), new PointF((float)(p2.X + dx), (float)(p2.Y + dy)));
                gr.DrawLine(pen1, p2, new PointF((float)(p2.X + dx + sx), (float)(p2.Y + dy + sy)));

                gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                    new PointF((float)(p1.X + dx), (float)(p1.Y + dy)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa - Math.PI / 2) * i))
                });
                gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                    new PointF((float)(p2.X + dx), (float)(p2.Y + dy)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa - Math.PI / 2) * i))
                });
                selectie1.Width = 1;
                gr.DrawPolygon(selectie1, new PointF[] {
                    new PointF((float)(p1.X + dx), (float)(p1.Y + dy)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa - Math.PI / 2) * i))
                });
                gr.DrawPolygon(selectie1, new PointF[] {
                    new PointF((float)(p2.X + dx), (float)(p2.Y + dy)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa - Math.PI / 2) * i))
                });

                Font f = new Font(FontFamily.GenericMonospace, 12);
                gr.TranslateTransform((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                gr.RotateTransform((float)(alfa * 180 / Math.PI + 180));
                SizeF size = gr.MeasureString(l, f);
                gr.TranslateTransform(-size.Width / 2, -size.Height - offset * tek.Schaal);

                GraphicsPath path = new GraphicsPath();
                path.AddString(l, f.FontFamily, (int)f.Style, f.SizeInPoints * 1.3f, new PointF(), new StringFormat());
                gr.DrawPath(Pens.Black, path);
                gr.FillPath(new SolidBrush(Color.FromArgb(255, pen.Color)), path);
                gr.ResetTransform();
            }
            else
            {
                Font f = new Font(FontFamily.GenericMonospace, 12);
                if (widepen)
                {
                    gr.TranslateTransform((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                    gr.RotateTransform((float)(alfa * 180 / Math.PI + 180));
                    SizeF size = gr.MeasureString(l, f);
                    gr.TranslateTransform(-size.Width / 2, -size.Height - offset);
                    gr.FillRectangle(Brushes.Black, 0, 0, size.Width, size.Height);
                    gr.ResetTransform();
                }
                else
                {
                    gr.DrawLine(pen1, p1, new PointF((float)(p1.X + dx + sx), (float)(p1.Y + dy + sy)));
                    gr.DrawLine(pen, new PointF((float)(p1.X + dx), (float)(p1.Y + dy)), new PointF((float)(p2.X + dx), (float)(p2.Y + dy)));
                    gr.DrawLine(pen1, p2, new PointF((float)(p2.X + dx + sx), (float)(p2.Y + dy + sy)));
                    gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                        new PointF((float)(p1.X + dx), (float)(p1.Y + dy)),
                        new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa + Math.PI / 2) * i)),
                        new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa - Math.PI / 2) * i))
                    });
                    gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                        new PointF((float)(p2.X + dx), (float)(p2.Y + dy)),
                        new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa + Math.PI / 2) * i)),
                        new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa - Math.PI / 2) * i))
                    });


                    gr.TranslateTransform((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                    gr.RotateTransform((float)(alfa * 180 / Math.PI + 180));
                    SizeF size = gr.MeasureString(l, f);
                    gr.TranslateTransform(-size.Width / 2, -size.Height - offset * tek.Schaal);
                    gr.DrawString(l, f, new SolidBrush(LijnKleur), new PointF());
                    gr.ResetTransform();
                }
            }
        }