Exemplo n.º 1
0
        private static void DrawArc(msgArc objA, RenderingMode mode, bool selSubObjects, bool asHot)
        {
            msgPointStruct[] pnts = objA.GetPoints();

            if (mode == RenderingMode.GL_RENDER)
            {
                OpenGLControl.glPushAttrib(OpenGLControl.GL_ENABLE_BIT |
                                           OpenGLControl.GL_LINE_BIT |
                                           OpenGLControl.GL_CURRENT_BIT |
                                           OpenGLControl.GL_LIGHTING_BIT);

                OpenGLControl.glDisable(OpenGLControl.GL_LIGHTING);
                OpenGLControl.glDisable(OpenGLControl.GL_TEXTURE_2D);
                OpenGLControl.glLineWidth((float)(objA.GetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS) + 1));


                /*GLushort pattern = GetLineTypeByIndex(objA->GetAttribute(SG_OA_LINE_TYPE));
                 * if (pattern > 0)
                 * {
                 *  glEnable(GL_LINE_STIPPLE);
                 *  glLineStipple(1, pattern);
                 * }*/

                if (asHot)
                {
                    OpenGLControl.glColor3f(1.0f, 0.0f, 0.0f);
                }
                else
                if (objA.IsSelect())
                {
                    OpenGLControl.glColor3f(1.0f, 0.0f, 0.0f);
                }
                else
                {
                    OpenGLControl.glColor3fv(GetColorByIndex(objA.GetAttribute(msgObjectAttrEnum.SG_OA_COLOR)));
                }
                OpenGLControl.glEnable(OpenGLControl.GL_LINE_SMOOTH);
                OpenGLControl.glPushMatrix();
                if (objA.GetTempMatrix() != null)
                {
                    double[] transData = GetDoubles(objA.GetTempMatrix().GetTransparentData().values);
                    unsafe
                    {
                        fixed(double *matrixPtr = transData)
                        {
                            OpenGLControl.glMultMatrixd(matrixPtr);
                        }
                    }
                }
                OpenGLControl.glBegin(OpenGLControl.GL_LINE_STRIP);
                for (int i = 0; i < pnts.Length; i++)
                {
                    OpenGLControl.glVertex3d(pnts[i].x, pnts[i].y, pnts[i].z);
                }
                OpenGLControl.glEnd();

                OpenGLControl.glPopMatrix();
                OpenGLControl.glPopAttrib();
            }
        }
Exemplo n.º 2
0
        private static void DrawLine(msgLine objL, RenderingMode mode, bool selSubObjects, bool asHot)
        {
            msgLineStruct ln = objL.GetGeometry();

            double[] pnts1 = new double[3];
            pnts1[0] = ln.P1.x;
            pnts1[1] = ln.P1.y;
            pnts1[2] = ln.P1.z;
            double[] pnts2 = new double[3];
            pnts2[0] = ln.P2.x;
            pnts2[1] = ln.P2.y;
            pnts2[2] = ln.P2.z;

            if (mode == RenderingMode.GL_RENDER)
            {
                OpenGLControl.glPushAttrib(OpenGLControl.GL_ENABLE_BIT |
                                           OpenGLControl.GL_LINE_BIT |
                                           OpenGLControl.GL_CURRENT_BIT |
                                           OpenGLControl.GL_LIGHTING_BIT);

                OpenGLControl.glDisable(OpenGLControl.GL_LIGHTING);
                OpenGLControl.glDisable(OpenGLControl.GL_TEXTURE_2D);
                OpenGLControl.glLineWidth((float)(objL.GetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS) + 1));

                /*GLushort pattern = GetLineTypeByIndex(objL->GetAttribute(SG_OA_LINE_TYPE));
                 * if (pattern>0)
                 * {
                 * glEnable(GL_LINE_STIPPLE);
                 * glLineStipple(1, pattern);
                 * }*/

                if (asHot)
                {
                    OpenGLControl.glColor3f(1.0f, 0.0f, 0.0f);
                }
                else
                if (objL.IsSelect())
                {
                    OpenGLControl.glColor3f(1.0f, 0.0f, 0.0f);
                }
                else
                {
                    OpenGLControl.glColor3fv(GetColorByIndex(objL.GetAttribute(msgObjectAttrEnum.SG_OA_COLOR)));
                }
                OpenGLControl.glEnable(OpenGLControl.GL_LINE_SMOOTH);
                OpenGLControl.glPushMatrix();
                if (objL.GetTempMatrix() != null)
                {
                    double[] transData = GetDoubles(objL.GetTempMatrix().GetTransparentData().values);
                    unsafe
                    {
                        fixed(double *matrixPtr = transData)
                        {
                            OpenGLControl.glMultMatrixd(matrixPtr);
                        }
                    }
                }
                OpenGLControl.glBegin(OpenGLControl.GL_LINES);
                OpenGLControl.glVertex3dv(pnts1);
                OpenGLControl.glVertex3dv(pnts2);
                OpenGLControl.glEnd();

                OpenGLControl.glPopMatrix();
                OpenGLControl.glPopAttrib();
            }
        }