Beispiel #1
0
        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");
        }
Beispiel #2
0
        private void saveDxfBtn_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "DXF Files|*.dxf";
            saveFileDialog.RestoreDirectory = true;
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                String strFilePath = saveFileDialog.FileName;

                // save the remnant material as dxf file.
                PolyMatEx      polyMat      = NestFacadeEx.BuildRemnantMat(m_sheet, m_dConnectTol, Convert.ToDouble(mergeDisTextBox.Text));
                GeomItemListEx geomItemList = polyMat.GetGeomItemList();
                NestFacadeEx.GeomItems2DxfDwg(geomItemList, strFilePath, false);
            }
        }
Beispiel #3
0
        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();
            /************************************************************************/
        }