Example #1
0
 protected override void OnCreated()
 {
     Device             = this;
     FO                 = new Drawing3d.Font("Arial");
     ActiveC            = new ActiveCursor();
     ActiveC.xAxisColor = Color.Red;
     ActiveC.yAxisColor = Color.Red;
     ActiveC.zAxisColor = Color.Red;
     ActiveC.PenWidth   = 3;
     SetEntityKind(Entitykind.Boxentity);
 }
Example #2
0
        /// <summary>
        /// overrides the draw nethod and paints the axis.
        /// </summary>
        /// <param name="Device"></param>
        protected override void OnDraw(OpenGlDevice Device)
        {
            if (FullSize)
            {
                xy WE = Device.WorldExtensions;
                if (WE.dist(Size.toXY()) > 0.2)
                {
                    SetInvalid(true);
                }
                Size = new xyz(WE.x, WE.y, WE.x);
            }
            if (Font == null)
            {
                Font = new Drawing3d.Font(FontName);
            }
            SaveFontSize  = Font.FontSize;
            Font.FontSize = TextHeight;
            base.OnDraw(Device);
            Device.PushMatrix();
            Device.MulMatrix(AxesBase.ToMatrix());
            bool SaveLighting = Device.LightEnabled;

            Device.LightEnabled = false;
            Color Save = Device.Emission;

            Device.Emission = Color;

            if (LeftAndRight)
            {
                Device.drawLine(new xyz(-Size.x, 0, 0), new xyz(Size.x, 0, 0));
                Device.drawLine(new xyz(0, -Size.y, 0), new xyz(0, Size.y, 0));
                if (Dim3d)
                {
                    Device.drawLine(new xyz(0, 0, -Size.z), new xyz(0, 0, Size.z));
                }
            }

            {
                Device.drawLine(new xyz(0, 0, 0), new xyz(Size.x, 0, 0));
                Device.drawLine(new xyz(0, 0, 0), new xyz(0, Size.y, 0));
                if (Dim3d)
                {
                    Device.drawLine(new xyz(0, 0, 0), new xyz(0, 0, Size.z));
                }
            }

            xyz n1   = new xyz(0, DeviderLineLength, 0);
            int from = (int)(-Size.x / Devider.x);

            if (!LeftAndRight)
            {
                from = 0;
            }

            if (Device.RenderKind == RenderKind.Render)
            {
                for (int i = from; i <= Size.x / Devider.x; i++)
                {
                    if (ShowDevider)
                    {
                        Device.drawLine(new xyz(Devider.x * i, 0, 0) - n1, new xyz(Devider.x * i, 0, 0) + n1);
                    }
                    if (ShowText)
                    {
                        double Pos = Devider.x * i - ((float)Device.getEnvText(Font, i.ToString()).x / 2f);

                        Device.drawText(Font, Matrix.Translation(new xyz(Pos, DeviderLineLength, 0)), i.ToString(), 0);
                    }
                }


                from = (int)(-Size.y / Devider.y);
                if (!LeftAndRight)
                {
                    from = 0;
                }
                n1 = new xyz(DeviderLineLength, 0, 0);
                for (int i = from; i <= Size.y / Devider.y; i++)
                {
                    if (i != 0)
                    {
                        if (ShowDevider)
                        {
                            Device.drawLine(new xyz(0, Devider.y * i, 0) - n1, new xyz(0, Devider.y * i, 0) + n1);
                        }
                        if (ShowText)
                        {
                            double Pos = Devider.x * i - ((float)Device.getEnvText(Font, i.ToString()).y / 2f);

                            Device.drawText(Font, Matrix.Translation(new xyz(DeviderLineLength, Pos, 0)), i.ToString(), 0);
                        }
                    }
                }
                if (Dim3d)
                {
                    for (int i = from; i <= Size.z / Devider.z; i++)
                    {
                        if (i != 0)
                        {
                            if (ShowDevider)
                            {
                                Device.drawLine(new xyz(0, 0, Devider.z * i) - n1, new xyz(0, 0, Devider.z * i) + n1);
                            }
                            if (ShowText)
                            {
                                double Pos = Devider.z * i - ((float)Device.getEnvText(Font, i.ToString()).y / 2f);

                                Device.drawText(Font, Matrix.Translation(new xyz(DeviderLineLength, 0, Pos)), i.ToString(), 0);
                            }
                        }
                    }
                }
            }
            if (Device.RenderKind == RenderKind.SnapBuffer)
            {
                if (LeftAndRight)
                {
                    Device.drawLine(new xyz(-Size.x, 0, 0), new xyz(Size.x, 0, 0));
                    Device.drawLine(new xyz(0, -Size.y, 0), new xyz(0, Size.y, 0));
                    if (Dim3d)
                    {
                        Device.drawLine(new xyz(0, 0, -Size.z), new xyz(0, 0, Size.z));
                    }
                }
                else
                if (LeftAndRight)
                {
                    Device.drawLine(new xyz(0, 0, 0), new xyz(Size.x, 0, 0));
                    Device.drawLine(new xyz(0, 0, 0), new xyz(0, Size.y, 0));
                    if (Dim3d)
                    {
                        Device.drawLine(new xyz(0, 0, 0), new xyz(0, 0, Size.z));
                    }
                }
                for (int i = from; i <= Size.x / Devider.x; i++)
                {
                    Device.drawPoint(new xyz(Devider.x * i, 0, 0), Devider.x / 4);
                    if (ShowText)
                    {
                        double        Pos = Devider.x * i - ((float)Device.getEnvText(Font, i.ToString()).x / 2f);
                        MeshContainer M   = MeshCreator.MeshListCurrent;
                        Device.drawText(Font, Matrix.Translation(new xyz(Pos, DeviderLineLength, 0)), i.ToString(), 0);
                        M = MeshCreator.MeshListCurrent;
                    }
                }


                from = (int)(-Size.y / Devider.y);
                if (!LeftAndRight)
                {
                    from = 0;
                }
                n1 = new xyz(DeviderLineLength, 0, 0);
                for (int i = from; i <= Size.y / Devider.y; i++)
                {
                    if (i != 0)
                    {
                        Device.drawPoint(new xyz(0, Devider.y * i, 0), Devider.x / 4);
                        if (ShowText)
                        {
                            double Pos = Devider.x * i - ((float)Device.getEnvText(Font, i.ToString()).y / 2f);

                            Device.drawText(Font, Matrix.Translation(new xyz(DeviderLineLength, Pos, 0)), i.ToString(), 0);
                        }
                    }
                }
                if (Dim3d)
                {
                    for (int i = from; i <= Size.z / Devider.z; i++)
                    {
                        if (i != 0)
                        {
                            Device.drawPoint(new xyz(0, 0, Devider.z * i), Devider.x / 4);

                            if (ShowText)
                            {
                                double Pos = Devider.z * i - ((float)Device.getEnvText(Font, i.ToString()).y / 2f);

                                Device.drawText(Font, Matrix.Translation(new xyz(DeviderLineLength, 0, Pos)), i.ToString(), 0);
                            }
                        }
                    }
                }
            }

            Device.Emission     = Save;
            Device.LightEnabled = SaveLighting;
            Font.FontSize       = SaveFontSize;
            Device.PopMatrix();
        }