Browse Source

improve the prj file's "save as" function . smooth the measure the same measure area function.

gsp 1 year ago
parent
commit
9cae022917

+ 4 - 4
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSSample.cs

@@ -145,6 +145,7 @@ namespace OTSDataType
             for (int i = 0; i < m_listFieldData.Count; i++)
             {
                 m_listFieldData[i].SetId(i);
+                m_listFieldData[i].Sample = this;
             }
             var mySemdata = GetSEMDataMsr();
 
@@ -160,7 +161,7 @@ namespace OTSDataType
             int nNewFieldId;
             nNewFieldId =GetIdForANewField();
             newfld.SetId(nNewFieldId);
-            
+            newfld.Sample = this;
 
            
             m_listFieldData.Add(newfld);
@@ -178,7 +179,7 @@ namespace OTSDataType
             int nNewFieldId;
             nNewFieldId = GetIdForANewField();
             newfld.SetId(nNewFieldId);
-
+            newfld.Sample = this;
 
 
             m_listFieldData.Add(newfld);
@@ -241,8 +242,7 @@ namespace OTSDataType
             bool bHasResult = (m_poMsrResults.GetResultItems().Count != 0);
             return bHasResult;
         }
-        //public MEMBRANE_TYPE GetMembraneType() { return m_membraneType; }
-        //public void SetMembraneType(MEMBRANE_TYPE val) { m_membraneType = val; }
+       
 
         public bool IsThisPointInMeasureArea(Point p)
         {

+ 5 - 0
OTSIncAMeasureApp/1-OTSMeasure/Measure/ParamData/COTSMsrPrjResultData.cs

@@ -48,6 +48,8 @@ namespace OTSModelSharp
 
 
         private otsdataconst.OTS_SysType_ID systemTypeId;
+        private List<Point> listCenterPoint;
+        private Size rectSize;
 
         public OTS_SysType_ID SystemTypeId { get => systemTypeId; set => systemTypeId = value; }
 
@@ -176,6 +178,9 @@ namespace OTSModelSharp
                 smpl.SetMsrStatus(poMsrStatus);
                 smpl.SetMsrResults(poMsrResults);
 
+                
+                smpl.InitFieldPosData(out listCenterPoint, out rectSize);
+
             }
 
             if (m_listSamples.Count > 0)

+ 1 - 0
OTSIncAMeasureApp/2-OTSMeasureParamManage/COTSMeasureParam.cs

@@ -74,6 +74,7 @@ namespace OTSMeasureApp
         NLog.Logger log ;
 
         public CSpecialGrayRangeParam SpecialRanges { get => specialRanges; set => specialRanges = value; }
+        public List<COTSSample> MeasureSampleList { get => m_MeasureSampleList; set => m_MeasureSampleList = value; }
 
         public CStageParam GetStageParam()
         {

+ 31 - 21
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -238,27 +238,7 @@ namespace OTSMeasureApp
                         frmFieldStart.ShowDialog();
                         if (frmFieldStart.okcancel==true)
                         {
-                            m_MeasureAppForm.m_ProjParam.InitWorkingSampleData(frmFieldStart.fieldStartNo);
-                            m_MeasureAppForm.InitCurrentSampleState();
-
-                            var visualsam = GetWorkingVisualSample();
-                            var sam=m_MeasureAppForm.m_ProjRstData.GetWorkingSample();
-                            var allflds = sam.GetFieldsData();
-
-                            foreach (var f in allflds)
-                            {
-                                if (f.GetMeasureSequence() >= frmFieldStart.fieldStartNo)
-                                {
-                                    Color ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.FieldColor);
-                                    ChangeMeasureFieldColor(visualsam, f.GetOTSPosition(), ColorStr);
-                                   
-                                }
-                               
-                            }
-                            
-
-                            m_MeasureAppForm.m_MeasureResultWindow.UpdateResultInfoBySampleName(sam.GetName());
-
+                            InitSampleMeasure(m_MeasureAppForm.m_ProjParam.GetWorkSample(), frmFieldStart.fieldStartNo);
                            
                         }
                     }
@@ -281,6 +261,36 @@ namespace OTSMeasureApp
             }
         }
         #endregion
+
+        public void InitSampleMeasure(COTSSample smpl,int fieldStartNo)
+
+        {
+            m_MeasureAppForm.m_ProjParam.SetWorkSample(smpl.GetName());
+            m_MeasureAppForm.m_ProjParam.InitWorkingSampleData(fieldStartNo);
+            m_MeasureAppForm.InitCurrentSampleState();
+            m_MeasureAppForm.m_MsrThreadWrapper.m_measure.mapSmplMsr.Clear();
+
+            var visualsam = GetWorkingVisualSample();
+            var sam = m_MeasureAppForm.m_ProjRstData.GetWorkingSample();
+            var allflds = sam.GetFieldsData();
+
+            foreach (var f in allflds)
+            {
+                if (f.GetMeasureSequence() >= fieldStartNo)
+                {
+                    Color ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.FieldColor);
+                    ChangeMeasureFieldColor(visualsam, f.GetOTSPosition(), ColorStr);
+
+                }
+
+            }
+
+
+            m_MeasureAppForm.m_MeasureResultWindow.UpdateResultInfoBySampleName(sam.GetName());
+
+
+
+        }
         /// <summary>
         /// 画圆形测试区域 事件
         /// </summary>

+ 8 - 4
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -853,10 +853,14 @@ namespace OTSMeasureApp
             {
                 return;
             }
-            m_ProjParam.InitWorkingSampleData(0);
-            this.InitCurrentSampleState();
-             m_MeasureResultWindow.SetInit();
-            m_SamplepaceWindow. PrepareMeasureField(m_SamplepaceWindow.GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
+            foreach (var spl in m_ProjParam.MeasureSampleList)
+            {
+                m_SamplepaceWindow.InitSampleMeasure(spl, 0);
+            }
+            //m_ProjParam.InitWorkingSampleData(0);
+            //this.InitCurrentSampleState();
+            // m_MeasureResultWindow.SetInit();
+            m_SamplepaceWindow.PrepareMeasureField(m_SamplepaceWindow.GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
         }
 
         private void rbSaveFile_Click(object sender, EventArgs e)

+ 1 - 0
OTSIncAMeasureApp/ServiceCenter/OxfordExtender/OxfordScanController.cs

@@ -45,6 +45,7 @@ namespace OTSMeasureApp.ServiceCenter
                 p.height = imageHeight;
                 p.DwellTime = dwelltime;
                 p.sourceType = imagesourceType;
+              
                 NLog.LogManager.GetCurrentClassLogger().Info("Begin to acquire BSE image!");
                 iExtender.AquisitionImage(ref p);
                 NLog.LogManager.GetCurrentClassLogger().Info("End acquiring BSE image!");

+ 39 - 17
OxfordExtenderWrapper/ExtenderWrapper.cs

@@ -16,6 +16,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading;
+using System.Windows;
 using System.Windows.Forms;
 using static OxfordExtenderWrapper.ExtenderIpcUI;
 
@@ -157,16 +158,23 @@ namespace OxfordExtenderWrapper
     [Serializable]
     public class ImageAquistionParam
     {
+        public enum ImageRegionType
+        {
+          FullField=0,
+          Rectangle=1
 
+        }
         public ImageAquistionParam()
         {
 
             this.ImageData = new byte[width * height];
-
+            regionType = ImageRegionType.FullField;
         }
         //in
+        public ImageRegionType regionType;
         public int width;
         public int height;
+        public Rect ImgRectRegion;
         public double DwellTime;
         public ImageInputSourceType sourceType;
         //out
@@ -365,8 +373,7 @@ namespace OxfordExtenderWrapper
             currentCommand.grabImgParam = p;
             currentCommand.commandType = OxfordCommandType.ImageAquisition;
 
-            SetImageAcquistionSetting(p.DwellTime, p.sourceType, p.width);
-
+            SetImageAcquistionSetting(p);
 
             try
             {
@@ -1376,8 +1383,11 @@ namespace OxfordExtenderWrapper
             512,
             704,
             768,
+            1408,
             1024,
+            1536,
             2048,
+            3072,
             4096,
             8192
         };
@@ -1522,8 +1532,8 @@ namespace OxfordExtenderWrapper
 
         //a_dDwellTime : 1~100000之间的数 
         //a_sImageType : 1: SE, 2: Bse
-        //a_dImageScanSize : 图像分辨率,图像的高
-        public bool SetImageAcquistionSetting(double a_dDwellTime, ImageInputSourceType a_nImageType, double a_dImageScanSize)
+       
+        public bool SetImageAcquistionSetting(ImageAquistionParam p)
         {
 
 
@@ -1533,45 +1543,57 @@ namespace OxfordExtenderWrapper
 
 
 
-            if (a_dDwellTime > imageCapabilities.MaximumImageDwellMicroseconds)
+            if (p.DwellTime > imageCapabilities.MaximumImageDwellMicroseconds)
             {
                 imageSettings.DwellTimeMicroSeconds = imageCapabilities.MaximumImageDwellMicroseconds;
             }
 
-            if (a_dDwellTime < imageCapabilities.MinimumImageDwellMicroseconds)
+            if (p.DwellTime < imageCapabilities.MinimumImageDwellMicroseconds)
             {
                 imageSettings.DwellTimeMicroSeconds = imageCapabilities.MinimumImageDwellMicroseconds;
             }
             else
             {
-                imageSettings.DwellTimeMicroSeconds = a_dDwellTime;
+                imageSettings.DwellTimeMicroSeconds = p.DwellTime;
             }
 
             imageSettings.InputSources.ToList().ForEach(i => imageSettings.EnableInputSource(i.Key, false));
-            imageSettings.EnableInputSource((ImageInputSources)a_nImageType, true);
+            imageSettings.EnableInputSource((ImageInputSources)p.sourceType, true);
 
-            if (!ImageScanSize.Contains(a_dImageScanSize))
+            if (!ImageScanSize.Contains(p.width))
             {
                 NLog.LogManager.GetCurrentClassLogger().Error("图像尺寸输入无效");
                 return false;
             }
 
-            var pixelSize = 1d / a_dImageScanSize;
+            var pixelSize = 1d / p.width;
+            if (p.regionType == ImageAquistionParam.ImageRegionType.FullField)
+            {
+                scanSettings.AcquisitionRegion.CreateFullFieldRegion(pixelSize);
+            }
+            else 
+            {
+
+                scanSettings.AcquisitionRegion.CreateRectangleRegion(p.ImgRectRegion,pixelSize);
+            }
+
+           
+
+           
 
 
-            scanSettings.AcquisitionRegion.CreateFullFieldRegion(pixelSize);
-            
             return true;
         }
+        
+
 
-       
         #endregion
 
         #region X-ray
-      
- 
 
-     
+
+
+
 
         void SetXrayAcquisitionParam(double a_dMilliSecondsTime)
         {

+ 35 - 22
OxfordExtenderWrapper/Form1.Designer.cs

@@ -29,10 +29,10 @@
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
-            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
-            System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
-            System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
-            System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+            System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+            System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
+            System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
             this.label1 = new System.Windows.Forms.Label();
             this.label2 = new System.Windows.Forms.Label();
@@ -179,6 +179,7 @@
             this.显示ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.隐藏ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.button30 = new System.Windows.Forms.Button();
             this.groupBox1.SuspendLayout();
             this.拍图.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.pBImage)).BeginInit();
@@ -1032,6 +1033,7 @@
             // 
             // 拍图
             // 
+            this.拍图.Controls.Add(this.button30);
             this.拍图.Controls.Add(this.cboSource);
             this.拍图.Controls.Add(this.txtBSEDwell);
             this.拍图.Controls.Add(this.txtBSEHeight);
@@ -1064,7 +1066,7 @@
             // 
             // txtBSEDwell
             // 
-            this.txtBSEDwell.Location = new System.Drawing.Point(451, 19);
+            this.txtBSEDwell.Location = new System.Drawing.Point(425, 19);
             this.txtBSEDwell.Name = "txtBSEDwell";
             this.txtBSEDwell.Size = new System.Drawing.Size(94, 21);
             this.txtBSEDwell.TabIndex = 3;
@@ -1111,7 +1113,7 @@
             // 
             this.label45.AutoSize = true;
             this.label45.ImeMode = System.Windows.Forms.ImeMode.NoControl;
-            this.label45.Location = new System.Drawing.Point(405, 22);
+            this.label45.Location = new System.Drawing.Point(379, 24);
             this.label45.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label45.Name = "label45";
             this.label45.Size = new System.Drawing.Size(41, 12);
@@ -1710,25 +1712,25 @@
             // 
             // chart1
             // 
-            chartArea1.Name = "ChartArea1";
-            this.chart1.ChartAreas.Add(chartArea1);
-            legend1.Alignment = System.Drawing.StringAlignment.Center;
-            legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
-            legend1.Name = "Legend1";
-            this.chart1.Legends.Add(legend1);
+            chartArea2.Name = "ChartArea1";
+            this.chart1.ChartAreas.Add(chartArea2);
+            legend2.Alignment = System.Drawing.StringAlignment.Center;
+            legend2.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
+            legend2.Name = "Legend1";
+            this.chart1.Legends.Add(legend2);
             this.chart1.Location = new System.Drawing.Point(554, 31);
             this.chart1.Margin = new System.Windows.Forms.Padding(2);
             this.chart1.Name = "chart1";
-            series1.ChartArea = "ChartArea1";
-            series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
-            series1.Legend = "Legend1";
-            series1.Name = "Series1";
-            series2.ChartArea = "ChartArea1";
-            series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
-            series2.Legend = "Legend1";
-            series2.Name = "Series2";
-            this.chart1.Series.Add(series1);
-            this.chart1.Series.Add(series2);
+            series3.ChartArea = "ChartArea1";
+            series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
+            series3.Legend = "Legend1";
+            series3.Name = "Series1";
+            series4.ChartArea = "ChartArea1";
+            series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
+            series4.Legend = "Legend1";
+            series4.Name = "Series2";
+            this.chart1.Series.Add(series3);
+            this.chart1.Series.Add(series4);
             this.chart1.Size = new System.Drawing.Size(593, 352);
             this.chart1.TabIndex = 3;
             this.chart1.Text = "chart1";
@@ -1793,6 +1795,16 @@
             this.退出ToolStripMenuItem.Text = "退出";
             this.退出ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click);
             // 
+            // button30
+            // 
+            this.button30.Location = new System.Drawing.Point(562, 18);
+            this.button30.Name = "button30";
+            this.button30.Size = new System.Drawing.Size(55, 23);
+            this.button30.TabIndex = 14;
+            this.button30.Text = "拍矩形";
+            this.button30.UseVisualStyleBackColor = true;
+            this.button30.Click += new System.EventHandler(this.button30_Click);
+            // 
             // Form1
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -1970,6 +1982,7 @@
         private System.Windows.Forms.ToolStripMenuItem 隐藏ToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem;
         private System.Windows.Forms.Button button17;
+        private System.Windows.Forms.Button button30;
     }
 }
 

+ 52 - 0
OxfordExtenderWrapper/Form1.cs

@@ -848,6 +848,58 @@ namespace OxfordExtenderWrapper
 
             }
         }
+
+        private void button30_Click(object sender, EventArgs e)
+        {
+            try
+            {
+
+                string path = System.Environment.CurrentDirectory;
+
+                ImageAquistionParam p = new ImageAquistionParam();
+                p.height = Convert.ToInt32(txtBSEHeight.Text);
+                p.width = Convert.ToInt32(txtBSEWidth.Text);
+                p.DwellTime = Convert.ToInt32(txtBSEDwell.Text);
+              
+                if (cboSource.Text == "BSE")
+                {
+                    p.sourceType = ExtenderIpcUI.ImageInputSourceType.Bse;
+                }
+                else
+                {
+                    p.sourceType = ExtenderIpcUI.ImageInputSourceType.SE;
+                }
+
+                p.ImageData = new byte[0];
+                var tr = new Thread(() =>
+                {
+
+
+                    iExtender.AquisitionImage(ref p);
+                }
+
+               );
+                tr.IsBackground = true;
+                tr.Start();
+                while (tr.IsAlive)
+                {
+                    Application.DoEvents();
+                }
+
+
+                var m_Bitmap = ToGrayBitmap(p.ImageData, p.width, p.height);
+
+                if (m_Bitmap != null)
+                {
+                    pBImage.Image = m_Bitmap;
+                }
+            }
+            catch (Exception r)
+            {
+                MessageBox.Show(r.Message);
+
+            }
+        }
     }
 
 }

+ 6 - 0
OxfordExtenderWrapper/Form1.resx

@@ -123,6 +123,12 @@
   <metadata name="含量.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="元素.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="含量.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="notifyIcon_wrapper.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 17</value>
   </metadata>