Пример #1
0
        private void Preview_selected_material()
        {
            // get the select material object.
            ListView.SelectedListViewItemCollection selItems = matListView.SelectedItems;
            if (selItems.Count == 0)
            {
                return;
            }
            ListViewItem item   = selItems[0];
            long         iMatID = (long)item.Tag;
            MatEx        mat    = m_matList.GetMatByID(iMatID);

            if (mat != null)
            {
                GeomItemListEx matGeomItems = mat.GetGeomItemList();

                // fit the geom to window.
                DrawHelper.FitWindow(matGeomItems.GetRectBox(), matViewPort, matPreviewWnd);

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

                // set the draw params.
                matViewPort.SetDrawColor(Color.White);
                matViewPort.SetLineWidth(1);

                matViewPort.DrawGeomItemList(matGeomItems);

                // swap buffer to display the geometry.
                matViewPort.SwapBuffers();
            }
        }
Пример #2
0
        private void SheetInfoForm_Paint(object sender, PaintEventArgs e)
        {
            if (m_sheet != null)
            {
                // clear screen and set the background color.
                m_shtViewPort.BindRendContext();
                m_shtViewPort.ClearScreen();
                m_shtViewPort.SetBackgroundColor(Color.Black);

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

                // draw material.
                DrawHelper.DrawMat(m_sheet.GetMat(), m_shtViewPort);

                // draw parts.
                DrawHelper.DrawPartPmts(m_sheet.GetPartPmtList(), m_selPartPmtList, m_shtViewPort, m_partColorConfig, m_impDataList);

                // swap buffer to display the geometry.
                m_shtViewPort.SwapBuffers();
            }
        }
Пример #3
0
        // preview the selected sheet.
        private void PreviewSheet()
        {
            // get the select sheet.
            ListView.SelectedListViewItemCollection selItems = shtListView.SelectedItems;
            if (selItems.Count == 0)
            {
                return;
            }
            ListViewItem item          = selItems[0];
            long         iSheetID      = (long)item.Tag;
            SheetEx      selectedSheet = m_sheetList.GetSheetByID(iSheetID);

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

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

            // draw material.
            DrawHelper.DrawMat(selectedSheet.GetMat(), m_shtViewPort);

            // draw parts.
            DrawHelper.DrawPartPmts(selectedSheet.GetPartPmtList(), null, m_shtViewPort, m_partColorConfig, m_impDataList);

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

            // the rect of part region.
            Rect2DEx partsRect = selectedSheet.GetPartPmtList().GetRectBox();

            partRegionTextBox.Text = partsRect.GetWidth().ToString("0.000") + " * " + partsRect.GetHeight().ToString("0.000");
        }
Пример #4
0
        private void Preview_selected_part()
        {
            // get the select NestPartEx object.
            ListView.SelectedListViewItemCollection selItems = partListView.SelectedItems;
            if (selItems.Count == 0)
            {
                return;
            }
            ListViewItem item        = selItems[0];
            long         iNestPartID = (long)item.Tag;
            NestPartEx   nestPart    = m_nestPartList.GetNestPartByID(iNestPartID);

            if (nestPart != null)
            {
                PartEx         part          = nestPart.GetPart();
                GeomItemListEx partGeomItems = part.GetGeomItemList();

                // fit the geom to window.
                DrawHelper.FitWindow(partGeomItems.GetRectBox(), partViewPort, partPreviewWnd);

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

                // set the draw params.
                partViewPort.SetDrawColor(ColorTranslator.FromOle(m_partColorConfig[nestPart.GetPart().GetID()]));
                partViewPort.SetLineWidth(1);

                partViewPort.DrawGeomItemList(partGeomItems);

                // swap buffer to display the geometry.
                partViewPort.SwapBuffers();
                //Graphics g = partPreviewWnd.Graphics;
            }
        }
Пример #5
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();
            }
        }