예제 #1
0
        public override void Draw(GlRectangle Border)
        {
            if (Border == null || !ActivateDrawStart())
            {
                return;
            }

            ActivateDrawing();

            GlPointR2[] I = this.getIntersection(Border);

            switch (I.Length)
            {
            case 0:
                if (OnDrawed != null)
                {
                    OnDrawed.Invoke(this);
                }
                return;

            case 1: new GlLineSegment(I[0], I[0]).Draw();
                break;

            case 2: new GlLineSegment(I[0], I[1]).Draw();
                break;
            }

            ActivateDrawed();
        }
예제 #2
0
 public GlRectangle(GlRectangle copyRectangle) :
     this(copyRectangle == null ? new GlPointR2(float.NaN, float.NaN) : copyRectangle.leftTopPoint,
          copyRectangle == null ? 0 : copyRectangle.Width,
          copyRectangle == null ? 0 : copyRectangle.Height,
          copyRectangle == null ? new GlVectorR2(0, 0) : copyRectangle.directVector)
 {
 }
예제 #3
0
        public void Draw(GlRectangle Border, GlColor drawColor, float drawWidth)
        {
            float curWidth = this.getCurrentGlWidth();

            Gl.glLineWidth(drawWidth);
            this.Draw(Border, drawColor);
            Gl.glLineWidth(curWidth);
        }
예제 #4
0
        /// <summary>
        /// Draw the point if it is inside the border rectangle
        /// </summary>
        public override void Draw(GlRectangle Border)
        {
            if (Border == null || !Border.isPointInside(this))
            {
                return;
            }

            this.Draw();
        }
예제 #5
0
        public override void Draw(GlRectangle Border)
        {
            if (Border == null)
            {
                return;
            }

            this.DrawFigures((F) => { F.Draw(Border); });
        }
예제 #6
0
        public void DrawFill(GlRectangle Border, GlColor drawColor)
        {
            GlColor curColor = this.getCurrentGlColor();

            if (drawColor != null)
            {
                Gl.glColor3f(drawColor.R, drawColor.G, drawColor.B);
            }

            this.DrawFill(Border);
            Gl.glColor3f(curColor.R, curColor.G, curColor.B);;
        }
예제 #7
0
        private void DrawFigures(FigureDrawBorder DrawMethod, GlRectangle Border)
        {
            if (!ActivateDrawStart())
            {
                return;
            }

            ActivateDrawing();

            foreach (GlFigure F in this.figuresAmount)
            {
                DrawMethod.Invoke(F, Border);
            }

            ActivateDrawed();
        }
예제 #8
0
 /// <summary>
 /// Draw the point if it is inside the border rectangle
 /// </summary>
 public override void DrawFill(GlRectangle Border)
 {
     this.Draw(Border);
 }
예제 #9
0
 public override void DrawFill(GlRectangle Border)
 {
     this.DrawFigures((F) => { F.DrawFill(Border); });
 }
예제 #10
0
 /// <summary>
 /// Draws filled a part of the figure that is inside the border rectangle
 /// </summary>
 /// <param name="Border">border rectangle</param>
 public abstract void DrawFill(GlRectangle Border);
예제 #11
0
        private void DrawPoints(GlRectangle Border, int GlDrawMode)
        {
            if (Border == null || !ActivateDrawStart())
            {
                return;
            }

            ActivateDrawing();

            bool isInside = Border.isPointInside(this[0]);

            GlPolygon ToDraw = new GlPolygon(this.Center);

            if (Border.isPointInside(this[this.CountOfPoints - 1]) != isInside)
            {
                if (!isInside)
                {
                    ToDraw.AddVertex(this[this.CountOfPoints - 1]);
                }

                GlPointR2[] I = new GlLineR2(this[0], new GlVectorR2(this[0].X - this[this.CountOfPoints - 1].X,
                                                                     this[0].Y - this[this.CountOfPoints - 1].Y)).getIntersection(Border);

                if (I.Length == 2)
                {
                    ToDraw.AddVertex(new GlLineSegment(this[this.CountOfPoints - 1], this[0]).isPointBelongs(I[0]) ? I[0] : I[1]);
                }
                else if (I.Length == 1 && new GlLineSegment(this[this.CountOfPoints - 1], this[0]).isPointBelongs(I[0]))
                {
                    ToDraw.AddVertex(I[0]);
                }
            }

            for (int i = 0; i < this.CountOfPoints - 1; i++)
            {
                if (isInside)
                {
                    ToDraw.AddVertex(this[i]);
                }
                if (Border.isPointInside(this[i + 1]) != isInside)
                {
                    GlPointR2[] I = new GlLineR2(this[i], new GlVectorR2(this[i + 1].X - this[i].X,
                                                                         this[i + 1].Y - this[i].Y)).getIntersection(Border);

                    if (I.Length == 2)
                    {
                        ToDraw.AddVertex(new GlLineSegment(this[i], this[i + 1]).isPointBelongs(I[0]) ? I[0] : I[1]);
                    }
                    else if (I.Length == 1 && new GlLineSegment(this[i], this[i + 1]).isPointBelongs(I[0]))
                    {
                        ToDraw.AddVertex(I[0]);
                    }

                    isInside = !isInside;
                }
            }

            Gl.glBegin(GlDrawMode);
            for (int i = 0; i < ToDraw.CountOfPoints; i++)
            {
                if (ToDraw[i] != null)
                {
                    Gl.glVertex2f(ToDraw[i].X, ToDraw[i].Y);
                }
            }
            Gl.glEnd();

            ActivateDrawed();
        }
예제 #12
0
 public override void DrawFill(GlRectangle Border)
 {
     DrawPoints(Border, Gl.GL_POLYGON);
 }
예제 #13
0
 public override void Draw(GlRectangle Border)
 {
     DrawPoints(Border, Gl.GL_LINE_STRIP);
 }