Ejemplo n.º 1
0
        private void RemnantMatInfoForm_Paint(object sender, PaintEventArgs e)
        {
            if (m_polyMat != null)
            {
                // all polygons in material.
                Poly2DListEx poly2DList = new Poly2DListEx();
                poly2DList.AddPoly(m_polyMat.GetMatPolygon());
                poly2DList.AddPolyList(m_polyMat.GetUselessHoleList());

                // clear screen and set the background color.
                m_matViewPort.BindRendContext();
                m_matViewPort.ClearScreen();
                m_matViewPort.SetBackgroundColor(Color.Black);

                // draw coordinate.
                m_matViewPort.SetDrawColor(Color.Blue);
                m_matViewPort.SetLineWidth(1);
                m_matViewPort.DrawCoordinate(0, 0, 0, false);

                // draw material polygons.
                m_matViewPort.SetDrawColor(Color.White);
                m_matViewPort.SetLineWidth(1);
                for (int i = 0; i < poly2DList.Size(); i++)
                {
                    Polygon2DEx poly      = poly2DList.GetPolygonByIndex(i);
                    ArrayList   lineItems = poly.GetLineList();
                    for (int j = 0; j < lineItems.Count; j++)
                    {
                        m_matViewPort.DrawLineItem((LineItemEx)lineItems[j]);
                    }
                }

                // draw selected polygon.
                if (m_selPoly != null)
                {
                    // hold the current drawing mode.
                    ROP_MODE_EX iOldRopMode = ROP_MODE_EX.ROP_EX_NORMAL;
                    m_matViewPort.GetROP(ref iOldRopMode);

                    // hold the current drawing width.
                    int iOldLineWid = m_matViewPort.GetLineWidth();

                    // hold the current drawing color.
                    Color oldColor = new Color();
                    m_matViewPort.GetDrawColor(ref oldColor);

                    // get the stipple mode.
                    bool   bOldStipple = false;
                    int    iOldRepeat  = 1;
                    ushort iOldPattern = 0xffff;
                    m_matViewPort.GetLineStipple(ref bOldStipple, ref iOldRepeat, ref iOldPattern);

                    // draw selected part placements.
                    m_matViewPort.SetROP(ROP_MODE_EX.ROP_EX_COPY);
                    m_matViewPort.SetLineWidth(2);
                    m_matViewPort.SetDrawColor(Color.Red);
                    m_matViewPort.SetLineStipple(true, 2, 0xcccc);
                    ArrayList lineItems = m_selPoly.GetLineList();
                    for (int j = 0; j < lineItems.Count; j++)
                    {
                        m_matViewPort.DrawLineItem((LineItemEx)lineItems[j]);
                    }

                    // restore the old drawer config.
                    m_matViewPort.SetROP(iOldRopMode);
                    m_matViewPort.SetLineWidth(iOldLineWid);
                    m_matViewPort.SetDrawColor(oldColor);
                    m_matViewPort.SetLineStipple(bOldStipple, iOldRepeat, iOldPattern);
                }

                // swap buffer to display the geometry.
                m_matViewPort.SwapBuffers();
            }
        }