示例#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
        // draw the material.
        static public void DrawMat(MatEx mat, GlViewPortEx viewPort)
        {
            viewPort.SetDrawColor(Color.White);
            viewPort.SetLineWidth(1);

            if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
            {
                RectMatEx   rectMat = (RectMatEx)mat;
                Rect2DEx    rect2D  = rectMat.GetBoundaryRect();
                Polygon2DEx poly    = new Polygon2DEx();
                poly.AddPoint(new Point2DEx(rect2D.GetXMin(), rect2D.GetYMin()));
                poly.AddPoint(new Point2DEx(rect2D.GetXMax(), rect2D.GetYMin()));
                poly.AddPoint(new Point2DEx(rect2D.GetXMax(), rect2D.GetYMax()));
                poly.AddPoint(new Point2DEx(rect2D.GetXMin(), rect2D.GetYMax()));
                viewPort.DrawPolygon(poly);
            }
            else if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
            {
                PolyMatEx   polyMat = (PolyMatEx)mat;
                Polygon2DEx poly    = polyMat.GetMatPolygon();
                viewPort.DrawPolygon(poly);

                // draw the useless holes.
                Poly2DListEx uselessHoles = polyMat.GetUselessHoleList();
                for (int i = 0; i < uselessHoles.Size(); i++)
                {
                    viewPort.DrawPolygon(uselessHoles.GetPolygonByIndex(i));
                }
            }
        }
示例#3
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();
            }
        }
示例#4
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");
        }
示例#5
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;
            }
        }
示例#6
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();
            }
        }
示例#7
0
        // draw the part placements.
        static public void DrawPartPmts(PartPmtListEx partPmts, PartPmtListEx selected_partPmts, GlViewPortEx viewPort, Dictionary <long, int> partColorConfig, ImpDataListEx impDataList)
        {
            for (int k = 0; k < partPmts.Size(); k++)
            {
                PartPmtEx partPmt = partPmts.GetPartPmtByIndex(k);
                PartEx    part    = partPmt.GetPart();

                // set the color and line width.
                if (selected_partPmts != null && selected_partPmts.GetPartPmtByID(partPmt.GetID()) != null)
                {
                    viewPort.SetLineWidth(6);
                    viewPort.SetDrawColor(Color.Red);
                }
                else
                {
                    viewPort.SetLineWidth(2);
                    int iColor = partColorConfig[part.GetID()];
                    viewPort.SetDrawColor(ColorTranslator.FromOle(iColor));
                }

                // get the ImpData object.
                ImpDataEx impData = null;
                for (int m = 0; m < impDataList.Size(); m++)
                {
                    ImpDataEx tmpImpData = impDataList.GetImpDataByIndex(m);
                    if (tmpImpData.GetPartID() == part.GetID())
                    {
                        impData = tmpImpData;
                        break;
                    }
                }

                // draw the first instance in the grid.
                {
                    // draw base geom.
                    GeomItemListEx geomItems_not_poly = impData.GetBaseGeomList();
                    if (geomItems_not_poly != null)
                    {
                        viewPort.DrawGeomItemList_With_Mat(geomItems_not_poly, partPmt.GetMatrix());
                    }

                    // draw poly data.
                    PolyDataListEx polyDataList = impData.GetPolyDataList();
                    if (polyDataList != null)
                    {
                        for (int m = 0; m < polyDataList.Size(); m++)
                        {
                            PolyDataEx polyData = polyDataList.GetPolyDataByIndex(m);
                            viewPort.DrawLoop_With_Mat(polyData, partPmt.GetMatrix());
                        }
                    }
                }


                // draw other parts in the grid.
                if (partPmt.IsGrid())
                {
                    int    iColCount = partPmt.GetColCount();
                    int    iRowCount = partPmt.GetRowCount();
                    double dSpacingX = partPmt.GetSpacingX();
                    double dSpacingY = partPmt.GetSpacingY();
                    for (int i = 0; i < iColCount; i++)
                    {
                        for (int j = 0; j < iRowCount; j++)
                        {
                            if (i == 0 && j == 0)
                            {
                                continue;
                            }

                            // prepare the transform matrix.
                            double     dOffsetX   = dSpacingX * i;
                            double     dOffsetY   = dSpacingY * j;
                            Vector2DEx offsetVect = new Vector2DEx(dOffsetX, dOffsetY);
                            Matrix2DEx mat        = partPmt.GetMatrix();
                            mat.Transfer(offsetVect.X(), offsetVect.Y());

                            // draw base geom.
                            GeomItemListEx geomItems_not_poly = impData.GetBaseGeomList();
                            if (geomItems_not_poly != null)
                            {
                                viewPort.DrawGeomItemList_With_Mat(geomItems_not_poly, mat);
                            }

                            // draw poly data.
                            PolyDataListEx polyDataList = impData.GetPolyDataList();
                            if (polyDataList != null)
                            {
                                for (int m = 0; m < polyDataList.Size(); m++)
                                {
                                    PolyDataEx polyData = polyDataList.GetPolyDataByIndex(m);
                                    viewPort.DrawLoop_With_Mat(polyData, mat);
                                }
                            }
                        }
                    }
                }
            }
        }