Beispiel #1
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);
                                }
                            }
                        }
                    }
                }
            }
        }