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(); } }
// 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"); }
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(); } }