Example #1
0
 private void buttonCancelRefCali_Click(object sender, EventArgs e)
 {
     IsRefSetting = false;
     RefIndex     = REF_NONE;
     refpoints.Clear();
     VSGlobalControl.CleanAllTestMark(selectBoxShowROI.Checked);
     MessageBox.Show("电芯基准设置取消。");
 }
Example #2
0
 private void comboBoxROI_SelectedIndexChanged(object sender, EventArgs e)
 {
     selectedROI = (CamCDIRoiName)Enum.Parse(typeof(CamCDIRoiName), comboBoxROI.Text);
     Cst.Struct_Image temp = VSGlobalControl.m_VParam.Im[(int)selectedROI];
     numericUpDownIgnoreWidth1.Value   = (decimal)temp.EdgeMultiplePoint.IgnoreLength1;
     numericUpDownIgnoreWidth2.Value   = (decimal)temp.EdgeMultiplePoint.IgnoreLength2;
     numericUpDownSampleNum.Value      = (decimal)temp.EdgeMultiplePoint.Robust.RobustSampleNum;
     numericUpDownMaxRobustCount.Value = (decimal)temp.EdgeMultiplePoint.Robust.MaxRobustCount;
     selectBoxPrint.Checked            = VSGlobalControl.m_VParam.Im[(int)selectedROI].EdgeMultiplePoint.PrintMultiplePoint;
     VSGlobalControl.CleanAllTestMark(false);
     VSTest.Vision_ShowRect(VSGlobalControl.m_VParam.Im[(int)selectedROI].EdgeMultiplePoint.Rect, VSBase.COLOR_YELLOW, Cst.ViewLWidth25);
     if (VisionControl.IsXLine(temp.EdgeMultiplePoint.Dir))
     {
         labelIgnoreWidth1.Text = "左边";
         labelIgnoreWidth2.Text = "右边";
     }
     else
     {
         labelIgnoreWidth1.Text = "上边";
         labelIgnoreWidth2.Text = "下边";
     }
 }
Example #3
0
 public void ClearMark()
 {
     IsRefSetting = false;
     refpoints.Clear();
     VSGlobalControl.CleanAllTestMark(selectBoxShowROI.Checked, optionBoxDispCellRef.Checked);
 }
Example #4
0
        private void CamDisplay4_MouseUp(object sender, MouseEventArgs e)
        {
            if (IsRefSetting)
            {
                Cst.dPoint temp = new Cst.dPoint(e.X, e.Y);
                refpoints.Add(temp);
                switch (refpoints.Count)
                {
                case 1:
                    VisionList[(int)BufferIndex.Test].Vision_DrawCross(e.X * 100 / VisionList[(int)BufferIndex.Test].Zoom, e.Y * 100 / VisionList[(int)BufferIndex.Test].Zoom, 40, VSBase.COLOR_CYAN, Cst.ViewLWidth50);
                    MessageBox.Show("已经设置第一个基准点。还有三个基准点。");
                    break;

                case 2:
                    VisionList[(int)BufferIndex.Test].Vision_DrawCross(e.X * 100 / VisionList[(int)BufferIndex.Test].Zoom, e.Y * 100 / VisionList[(int)BufferIndex.Test].Zoom, 40, VSBase.COLOR_CYAN, Cst.ViewLWidth50);
                    MessageBox.Show("已经设置第二个基准点。还有两个基准点。");
                    break;

                case 3:
                    VisionList[(int)BufferIndex.Test].Vision_DrawCross(e.X * 100 / VisionList[(int)BufferIndex.Test].Zoom, e.Y * 100 / VisionList[(int)BufferIndex.Test].Zoom, 40, VSBase.COLOR_CYAN, Cst.ViewLWidth50);
                    MessageBox.Show("已经设置第三个基准点。还有一个基准点。");
                    break;

                case 4:
                    Cst.dPoint centpoint = Cst.dPoint.GetAvg(refpoints.ToArray());
                    for (int i = 0; i < refpoints.Count; i++)
                    {
                        if (refpoints[i].X < centpoint.X)
                        {
                            if (refpoints[i].Y < centpoint.Y)
                            {
                                //左上
                                if (RefIndex == REF_GAUGE)
                                {
                                    VSGlobalControl.m_VGaugeParam.TopLeft = refpoints[i];
                                }
                                else
                                {
                                    VSGlobalControl.m_VParam.TopLeft = refpoints[i];
                                }
                            }
                            else
                            {
                                //左下
                                if (RefIndex == REF_GAUGE)
                                {
                                    VSGlobalControl.m_VGaugeParam.BottomLeft = refpoints[i];
                                }
                                else
                                {
                                    VSGlobalControl.m_VParam.BottomLeft = refpoints[i];
                                }
                            }
                        }
                        else
                        {
                            if (refpoints[i].Y < centpoint.Y)
                            {
                                //右上
                                if (RefIndex == REF_GAUGE)
                                {
                                    VSGlobalControl.m_VGaugeParam.TopRef = refpoints[i];
                                }
                                else
                                {
                                    VSGlobalControl.m_VParam.TopRef = refpoints[i];
                                }
                            }
                            else
                            {
                                //右下
                                if (RefIndex == REF_GAUGE)
                                {
                                    VSGlobalControl.m_VGaugeParam.BottomRef = refpoints[i];
                                }
                                else
                                {
                                    VSGlobalControl.m_VParam.BottomRef = refpoints[i];
                                }
                            }
                        }
                    }
                    //if (refpoints[0].Y > refpoints[1].Y)
                    //{
                    //    VSGlobalControl.m_VParam.BottomRef = refpoints[0];
                    //    VSGlobalControl.m_VParam.TopRef = refpoints[1];
                    //}
                    //else
                    //{
                    //    VSGlobalControl.m_VParam.BottomRef = refpoints[1];
                    //    VSGlobalControl.m_VParam.TopRef = refpoints[0];
                    //}
                    if (RefIndex == REF_GAUGE)
                    {
                        VSGlobalControl.m_VGaugeParam.BottomRef  *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VGaugeParam.TopRef     *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VGaugeParam.TopLeft    *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VGaugeParam.BottomLeft *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VGaugeParam.AvgRef      = Cst.dPoint.GetAvg(new Cst.dPoint[] { VSGlobalControl.m_VGaugeParam.BottomRef, VSGlobalControl.m_VGaugeParam.TopRef });
                        VSGlobalControl.SetROIByRef(MessageBox.Show("是否用当前标准块生成新模板?", "保存模板", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
                        MessageBox.Show("标准块基准设置完成。可点击“开始设置”重新设置基准。");
                        if (MessageBox.Show("是否需要对电芯基准进行设置?如果需要则先放置好电芯,然后点“是”开始电芯基准设置,需要略过则点“否”。", "电芯基准设置", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            RefIndex = REF_CELL;
                            MessageBox.Show("请先确定电芯已放好,点”确定“开始电芯基准设置。用鼠标点击图像中电芯主体边缘四个顶点。");
                        }
                        else
                        {
                            RefIndex = REF_NONE;
                        }
                    }
                    else
                    {
                        VSGlobalControl.m_VParam.BottomRef  *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VParam.TopRef     *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VParam.TopLeft    *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VParam.BottomLeft *= (double)100 / VSTest.Zoom;
                        VSGlobalControl.m_VParam.AvgRef      = Cst.dPoint.GetAvg(new Cst.dPoint[] { VSGlobalControl.m_VParam.BottomRef, VSGlobalControl.m_VParam.TopRef });
                        VSGlobalControl.SetROIByRef(false);
                        RefIndex = REF_NONE;
                        MessageBox.Show("电芯基准设置完成。可点击“开始设置”重新设置电芯基准。");
                    }
                    VSGlobalControl.ReadWriteProdVisionParam(false);
                    VSGlobalControl.CleanAllTestMark();
                    IsRefSetting = false;
                    break;
                }
            }
        }