Ejemplo n.º 1
0
        private void MaterialForm_Load(object sender, EventArgs e)
        {
            nameTextBox.Text  = m_mat.GetName();
            countTextBox.Text = m_mat.GetCount().ToString();

            if (m_mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
            {
                RectMatEx rectMat = (RectMatEx)(m_mat);
                Rect2DEx  rect    = rectMat.GetBoundaryRect();
                widthTextBox.Enabled  = true;
                widthTextBox.Text     = rect.GetWidth().ToString("0.000");
                heightTextBox.Enabled = true;
                heightTextBox.Text    = rect.GetHeight().ToString("0.000");
            }
            else if (m_mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
            {
                PolyMatEx   polyMat = (PolyMatEx)(m_mat);
                Polygon2DEx poly    = polyMat.GetMatPolygon();
                Rect2DEx    rect    = poly.GetBoundaryRect();
                widthTextBox.Enabled  = false;
                widthTextBox.Text     = rect.GetWidth().ToString("0.000");
                heightTextBox.Enabled = false;
                heightTextBox.Text    = rect.GetHeight().ToString("0.000");
            }
        }
Ejemplo n.º 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));
                }
            }
        }
Ejemplo n.º 3
0
        // add material to list control.
        private void AddMat(MatEx mat)
        {
            // the boundary rect of the material.
            Rect2DEx boundaryRect = null;

            if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
            {
                RectMatEx rectMat = (RectMatEx)mat;
                boundaryRect = rectMat.GetBoundaryRect();
            }
            else if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
            {
                PolyMatEx   polyMat = (PolyMatEx)mat;
                Polygon2DEx polygon = polyMat.GetMatPolygon();
                boundaryRect = polygon.GetBoundaryRect();
            }

            /************************************************************************/
            // add a row to list control.

            // insert a row.
            int          iCount = matListView.Items.Count + 1;
            ListViewItem item   = matListView.Items.Add(iCount.ToString());

            // name column.
            item.SubItems.Add(mat.GetName());

            // material type column.
            if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
            {
                item.SubItems.Add("矩形材料");
            }
            else if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
            {
                item.SubItems.Add("不规则材料");
            }

            // the material height.
            item.SubItems.Add(boundaryRect.GetHeight().ToString("0.000"));

            // the material width.
            item.SubItems.Add(boundaryRect.GetWidth().ToString("0.000"));

            // the material count.
            item.SubItems.Add(mat.GetCount().ToString());

            // hold the ID.
            item.Tag = mat.GetID();
            /************************************************************************/

            // select the last row.
            matListView.SelectedItems.Clear();
            matListView.Items[matListView.Items.Count - 1].Selected = true;
            matListView.Items[matListView.Items.Count - 1].Focused  = true;
            matListView.Items[matListView.Items.Count - 1].EnsureVisible();
        }
Ejemplo n.º 4
0
        private void editMatBtn_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection selItems = matListView.SelectedItems;
            if (selItems.Count != 1)
            {
                MessageBox.Show("Please select one row to edit.", "NestProfessor DEMO");
                return;
            }
            else
            {
                ListViewItem item   = selItems[0];
                long         iMatID = (long)item.Tag;
                MatEx        mat    = m_matList.GetMatByID(iMatID);
                if (mat != null)
                {
                    if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_POLY)
                    {
                        MessageBox.Show("For irregular material, its width and height can be edited here.", "NestProfessor DEMO");
                    }

                    MaterialForm matForm = new MaterialForm(mat);
                    if (matForm.ShowDialog() == DialogResult.OK)
                    {
                        /************************************************************************/
                        // update the list control.

                        // name column.
                        item.SubItems[1].Text = mat.GetName();

                        if (mat.GetMatType() == MAT_TYPE_EX.MAT_EX_RECT)
                        {
                            RectMatEx rectMat = (RectMatEx)(mat);
                            Rect2DEx  rect    = rectMat.GetBoundaryRect();

                            // the material width.
                            item.SubItems[3].Text = rect.GetWidth().ToString("0.000");

                            // the material height.
                            item.SubItems[4].Text = rect.GetHeight().ToString("0.000");
                        }

                        // count.
                        item.SubItems[5].Text = mat.GetCount().ToString();
                        /************************************************************************/

                        matPreviewWnd.Invalidate();
                    }
                }
            }
        }