private void RemnantMatInfoForm_Load(object sender, EventArgs e) { // build the remnant material from the sheet. double dMergeDis = 10; m_polyMat = NestFacadeEx.BuildRemnantMat(m_sheet, m_dConnectTol, dMergeDis); // init the tree. UpdateTree(); /************************************************************************/ // init the view port. m_matViewPort.InitEnv(matViewWnd.Handle, 0.00001, 10000); // all polygons in material. Poly2DListEx poly2DList = new Poly2DListEx(); poly2DList.AddPoly(m_polyMat.GetMatPolygon()); poly2DList.AddPolyList(m_polyMat.GetUselessHoleList()); // set the drawing area. Int32 iWidth = matViewWnd.Right - matViewWnd.Left; Int32 iHeight = matViewWnd.Bottom - matViewWnd.Top; Rect2DEx geomRect = poly2DList.GetRectBox(); Point2DEx leftBottomPt = new Point2DEx(); double dXDirRange = m_matViewPort.GetFitAllParam(iWidth, iHeight, geomRect, 1.2, leftBottomPt); m_matViewPort.SetDrawingArea(1.1 * dXDirRange, iWidth, iHeight, leftBottomPt); /************************************************************************/ mergeDisTextBox.Text = dMergeDis.ToString("0.000"); }
// fit the view port to the rect. static public void FitWindow(Rect2DEx geomRect, GlViewPortEx viewPort, Control window) { Int32 iWidth = window.Right - window.Left; Int32 iHeight = window.Bottom - window.Top; Point2DEx leftBottomPt = new Point2DEx(); double dXDirRange = viewPort.GetFitAllParam(iWidth, iHeight, geomRect, 1.2, leftBottomPt); viewPort.SetDrawingArea(1.1 * dXDirRange, iWidth, iHeight, leftBottomPt); }
private void matViewWnd_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Middle) { Point pt = new Point(e.X, e.Y); m_matViewPort.PanViewPort(pt.X - m_referPt.X, pt.Y - m_referPt.Y); m_referPt = pt; Invalidate(); } // display the current coordinate. Point2DEx currentPt = m_matViewPort.GetCursorPos(); posTextBox.Text = "x= " + currentPt.X().ToString("0.000") + ", y= " + currentPt.Y().ToString("0.000"); }
private void reGenBtn_Click(object sender, EventArgs e) { // verify input. try { Convert.ToDouble(mergeDisTextBox.Text); } catch (FormatException exception) { MessageBox.Show("Incorrect input: " + exception.Message, "NestProfessor DEMO"); return; } // re-generate the remnant material from the sheet. m_polyMat = NestFacadeEx.BuildRemnantMat(m_sheet, m_dConnectTol, Convert.ToDouble(mergeDisTextBox.Text)); // update tree nodes. UpdateTree(); /************************************************************************/ // adjust the drawing area. // the boundary rect of all polygons in material. Poly2DListEx poly2DList = new Poly2DListEx(); poly2DList.AddPoly(m_polyMat.GetMatPolygon()); poly2DList.AddPolyList(m_polyMat.GetUselessHoleList()); Rect2DEx geomRect = poly2DList.GetRectBox(); // set the drawing area. Int32 iWidth = matViewWnd.Right - matViewWnd.Left; Int32 iHeight = matViewWnd.Bottom - matViewWnd.Top; Point2DEx leftBottomPt = new Point2DEx(); double dXDirRange = m_matViewPort.GetFitAllParam(iWidth, iHeight, geomRect, 1.2, leftBottomPt); m_matViewPort.SetDrawingArea(1.1 * dXDirRange, iWidth, iHeight, leftBottomPt); m_selPoly = null; Invalidate(); /************************************************************************/ }