Example #1
0
        private void NestPartForm_Load(object sender, EventArgs e)
        {
            // the nesting priority.
            priorComboBox.Items.Add("1");
            priorComboBox.Items.Add("2");
            priorComboBox.Items.Add("3");
            priorComboBox.Items.Add("4");
            priorComboBox.Items.Add("5");
            priorComboBox.Items.Add("6");
            priorComboBox.Items.Add("7");
            priorComboBox.Items.Add("8");
            priorComboBox.Items.Add("9");
            priorComboBox.Items.Add("10");
            priorComboBox.SelectedIndex = m_nestPart.GetPriority().GetVal() - 1;

            // the nesting count.
            countTextBox.Text = m_nestPart.GetNestCount().ToString();

            // the part rotate angle.
            angleComboBox.Items.Add("自由旋转");
            angleComboBox.Items.Add("90度增量");
            angleComboBox.Items.Add("180度增量");
            angleComboBox.Items.Add("0度固定");
            angleComboBox.Items.Add("90度固定");
            angleComboBox.Items.Add("180度固定");
            angleComboBox.Items.Add("270度固定");
            angleComboBox.SelectedIndex = (int)m_nestPart.GetRotStyle();
        }
Example #2
0
        private void partListView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListView.SelectedListViewItemCollection selItems = partListView.SelectedItems;
            if (selItems.Count == 1)
            {
                ListViewItem item        = selItems[0];
                long         iNestPartID = (long)item.Tag;
                NestPartEx   nestPart    = m_nestPartList.GetNestPartByID(iNestPartID);
                if (nestPart != null)
                {
                    NestPartForm nestPartForm = new NestPartForm(nestPart);
                    if (nestPartForm.ShowDialog() == DialogResult.OK)
                    {
                        /************************************************************************/
                        // update the list control.

                        // priority column.
                        item.SubItems[2].Text = nestPart.GetPriority().GetVal().ToString();

                        // nest count column.
                        item.SubItems[3].Text = nestPart.GetNestCount().ToString();

                        // priority column.
                        item.SubItems[4].Text = NestHelper.GetRotateAngName(nestPart.GetRotStyle());
                        /************************************************************************/
                    }
                }
            }
        }
Example #3
0
        // add part to list control.
        private void AddPart_to_listCtrl(NestPartEx nestPart, string order)
        {
            // insert a row.
            int          iCount = partListView.Items.Count + 1;
            ListViewItem item   = partListView.Items.Add(iCount.ToString());

            // part name column.
            item.SubItems.Add(nestPart.GetPart().GetName());

            // priority column.
            item.SubItems.Add(nestPart.GetPriority().GetVal().ToString());

            // nest count column.
            item.SubItems.Add(nestPart.GetNestCount().ToString());

            // rotate angle column.
            String strRotateAng = NestHelper.GetRotateAngName(nestPart.GetRotStyle());

            string temp = string.Empty;

            switch (strRotateAng.Trim())
            {
            case "Free Rotate": temp = "自由旋转"; break;

            case "90 Increment": temp = "90度增量"; break;

            case "180 Increment": temp = "180度增量"; break;

            case "0 Fixed": temp = "0度固定"; break;

            case "90 Fixed": temp = "90度固定"; break;

            case "180 Fixed": temp = "180度固定"; break;

            case "270 Fixed": temp = "270度固定"; break;
            }

            item.SubItems.Add(temp);

            // "Part Size" column.
            Rect2DEx      partRect = nestPart.GetPart().GetGeomItemList().GetRectBox();
            StringBuilder sb       = new StringBuilder();

            sb.Append(partRect.GetWidth().ToString("0.00")).Append("(W) * ").Append(partRect.GetHeight().ToString("0.00")).Append("(H)");
            item.SubItems.Add(sb.ToString());

            //添加订单号
            item.SubItems.Add(order);

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

            OrderManagerDal.Instance.AddOrder(nestPart.GetPart().GetID(), order);
        }
Example #4
0
        static private void SaveNestParts(XmlDocument xmlDoc, XmlNode partListNode, NestPartListEx nestParts, List <KeyValuePair <long, string> > partDxfPath, Dictionary <long, int> partColorConfig)
        {
            for (int i = 0; i < nestParts.Size(); i++)
            {
                NestPartEx nestPart = nestParts.GetNestPartByIndex(i);

                XmlElement partNode = xmlDoc.CreateElement("Part");
                partListNode.AppendChild(partNode);

                // path node.
                {
                    for (int j = 0; i < partDxfPath.Count; j++)
                    {
                        if (partDxfPath[j].Key == nestPart.GetID())
                        {
                            XmlElement pathNode = xmlDoc.CreateElement("Path");
                            pathNode.InnerText = partDxfPath[j].Value;
                            partNode.AppendChild(pathNode);
                            break;
                        }
                    }
                }

                // Count
                {
                    XmlElement countNode = xmlDoc.CreateElement("Count");
                    countNode.InnerText = nestPart.GetNestCount().ToString();
                    partNode.AppendChild(countNode);
                }

                // Rotate.
                {
                    XmlElement rotateNode = xmlDoc.CreateElement("Rotate");
                    rotateNode.InnerText = ((int)nestPart.GetRotStyle()).ToString();
                    partNode.AppendChild(rotateNode);

                    // custom angles.
                    if (nestPart.GetRotStyle() == PART_ROT_STYLE_EX.PART_ROT_CUSTOM_ANG)
                    {
                        // the angle-string.
                        string    strAngs = "";
                        ArrayList angles  = nestPart.GetCustomRotAng();
                        for (int k = 0; k < angles.Count; k++)
                        {
                            double dAngle = (double)angles[k];
                            strAngs += dAngle.ToString("0.00000000");
                            strAngs += ",";
                        }

                        // append the node.
                        XmlElement customAngleNode = xmlDoc.CreateElement("CustomAng");
                        customAngleNode.InnerText = strAngs;
                        partNode.AppendChild(customAngleNode);
                    }
                }

                // part color.
                {
                    XmlElement colorNode = xmlDoc.CreateElement("Color");
                    colorNode.InnerText = partColorConfig[nestPart.GetPart().GetID()].ToString();
                    partNode.AppendChild(colorNode);
                }
            }
        }
Example #5
0
        // display the nesting result.
        private void DisplayNestResult()
        {
            if (m_sheetList == null)
            {
                return;
            }

            m_bDisableEvent = true;

            // display detail info of each sheet.
            shtListView.Items.Clear();
            for (int i = 0; i < m_sheetList.Size(); i++)
            {
                SheetEx sheet = m_sheetList.GetSheetByIndex(i);

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

                // "name" column.
                item.SubItems.Add(sheet.GetName());

                // "sheet count" column.
                item.SubItems.Add(sheet.GetCount().ToString());

                // "material name" column.
                item.SubItems.Add(sheet.GetMat().GetName());

                // hold the sheet ID.
                item.Tag = sheet.GetID();
            }

            /************************************************************************/
            // part group.

            NestPartListEx nestPartList = m_nestTask.GetNestPartList();

            // submitted part count.
            int iSubmitPartCount = 0;

            for (int i = 0; i < nestPartList.Size(); i++)
            {
                iSubmitPartCount += nestPartList.GetNestPartByIndex(i).GetNestCount();
            }
            subPartTextBox.Text = iSubmitPartCount.ToString();

            // the count of the nested parts.
            int iNestedPartCount = m_sheetList.GetPartInstTotalCount();

            nestPartTextBox.Text = iNestedPartCount.ToString();

            // display detailed info of each part.
            partListView.Items.Clear();
            for (int i = 0; i < nestPartList.Size(); i++)
            {
                NestPartEx nestPart = nestPartList.GetNestPartByIndex(i);
                PartEx     part     = nestPart.GetPart();

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

                // "name" column.
                item.SubItems.Add(part.GetName());

                // "submitted count" column.
                item.SubItems.Add(nestPart.GetNestCount().ToString());

                // "nested count" column.
                int iNestedCount = m_sheetList.GetPartInstCount(part.GetID());
                item.SubItems.Add(iNestedCount.ToString());
            }
            /************************************************************************/

            /************************************************************************/
            // material group.

            MatListEx matList = m_nestTask.GetMatList();

            // the utilization of material.
            double dUtilization = NestHelper.CalcMatUtil(m_sheetList, m_nestTask.GetNestParam());

            utilTextBox.Text = dUtilization.ToString("0.00");

            matListView.Items.Clear();
            for (int i = 0; i < matList.Size(); i++)
            {
                MatEx mat = matList.GetMatByIndex(i);

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

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

                // "submitted count" column.
                item.SubItems.Add(mat.GetCount().ToString());

                // "consumed count" column.
                int iConsumedCount = m_sheetList.GetSheetCount(mat.GetID());
                item.SubItems.Add(iConsumedCount.ToString());
            }
            /************************************************************************/

            // preview the first sheet.
            if (shtListView.Items.Count > 0)
            {
                shtListView.Items[0].Selected = true;

                // get the select sheet.
                ListView.SelectedListViewItemCollection selItems = shtListView.SelectedItems;
                ListViewItem item          = selItems[0];
                long         iSheetID      = (long)item.Tag;
                SheetEx      selectedSheet = m_sheetList.GetSheetByID(iSheetID);

                // fit the window.
                DrawHelper.FitWindow(selectedSheet.GetMat().GetBoundaryRect(), m_shtViewPort, shtPreViewWnd);

                PreviewSheet();
            }

            m_bDisableEvent = false;
        }