Pārlūkot izejas kodu

unify the merged particle and the simple particle into the same form and save into the same db table.

GSP 1 mēnesi atpakaļ
vecāks
revīzija
7be8d746a1

+ 60 - 1
OTSIncAMeasureApp/1-OTSMeasure/Measure/DBDataTransition/IncADataDB.cs

@@ -18,8 +18,67 @@ namespace OTSModelSharp
         {
 
         }
+        public bool SaveAParticle(COTSParticleClr a_pParticle, CPosXrayClr a_pXray)
+        {
+            var tableInfoPtr = GetTableInfo();
+            var datastorePtr = GetDatastore();
+            //Rectangle prec = (Rectangle)a_pParticle.GetParticleRect();
+            //System.Drawing.Point pos = (System.Drawing.Point)a_pParticle.GetSEMPos();
+
+            Rectangle rec = (Rectangle)a_pParticle.GetParticleRect();
+            System.Drawing.Point xrayPos = (System.Drawing.Point)a_pParticle.GetXRayPos();
+            System.Drawing.Point semPos = (System.Drawing.Point)a_pParticle.GetSEMPos();
+            String sInsertFormat = tableInfoPtr.GetInsertCommandFormatString(true);
+            var cmd = tableInfoPtr.GetInsertCommand(true);
+
+            var paras = cmd.Value;
+            paras[0].Value = a_pParticle.GetFieldId();
+            paras[1].Value = a_pParticle.GetAnalysisId();
+            paras[2].Value = a_pParticle.GetAveGray();
+            paras[3].Value = rec.Left;
+            paras[4].Value = rec.Top;
+            paras[5].Value = rec.Width;
+            paras[6].Value = rec.Height;
+            paras[7].Value = a_pParticle.GetActualArea();
+            paras[8].Value = xrayPos.X;
+            paras[9].Value = xrayPos.Y;
+
+            paras[10].Value = a_pParticle.GetFeretDiameter();
+            paras[11].Value = (int)(a_pParticle.GetFeature().GetSegmentsList().Count);
+            paras[12].Value = semPos.X;
+            paras[13].Value = semPos.Y;
+            paras[14].Value = a_pParticle.GetParticleId();
+            paras[15].Value = a_pParticle.GetDMAX();
+            paras[16].Value = a_pParticle.GetDMIN();
+            paras[17].Value = a_pParticle.GetDMPERP();
+            paras[18].Value = a_pParticle.GetDPRIMETER();
+            paras[19].Value = a_pParticle.GetORIENTATION();
+            paras[20].Value = a_pParticle.GetDINSCR();
+            paras[21].Value = a_pParticle.GetDMEAN();
+            paras[22].Value = a_pParticle.GetDELONG();
+            paras[23].Value = a_pParticle.GetClassifyId();
+            paras[24].Value = a_pParticle.GetTypeName();
+            paras[25].Value = a_pParticle.GetTypeColor();
+            paras[26].Value = semPos.X;
+            paras[27].Value = semPos.Y;
+            paras[28].Value = a_pParticle.GetGrpId();
+            paras[29].Value = a_pParticle.GetGrpName();
+            paras[30].Value = a_pParticle.GetGrpColor();
+
+            paras[27].Value = a_pParticle.GetConnectedParticlesName();
+
+            List<KeyValuePair<string, SQLiteParameter[]>> cmds = new List<KeyValuePair<string, SQLiteParameter[]>>();
+            cmds.Add(cmd);
+
+
+            datastorePtr.ExecuteNonQueryBatch(ref cmds);
+
+
+
+
+            return true;
+        }
 
-       
 
 
         public KeyValuePair<string,SQLiteParameter[]> GetUpdataAIncACmd(COTSParticleClr a_pParticle)

+ 2 - 2
OTSIncAMeasureApp/1-OTSMeasure/Measure/DBDataTransition/IncADataTable.cs

@@ -44,7 +44,7 @@ namespace OTSModelSharp
             N_GRPID=28,
             S_GRPNAME=29,
             S_GRPCOLOR=30,
-            //S_SubParticles = 31,
+            S_SubParticles = 31,
             MAX = 31
         }
 
@@ -86,7 +86,7 @@ namespace OTSModelSharp
             AddColumn(new ColumnDefine() { ColumName = "GroupId", ColumType = new ColumnType(ColumnType.ID.INTEGER, false, false), IsPrimarykey = false });
             AddColumn(new ColumnDefine() { ColumName = "GroupName", ColumType = new ColumnType(ColumnType.ID.STRING, false, false), IsPrimarykey = false });
             AddColumn(new ColumnDefine() { ColumName = "GroupColor", ColumType = new ColumnType(ColumnType.ID.STRING, false, false), IsPrimarykey = false });
-            //AddColumn(new ColumnDefine() { ColumName = "SubParticles", ColumType = new ColumnType(ColumnType.ID.STRING, false, false), IsPrimarykey = false });
+            AddColumn(new ColumnDefine() { ColumName = "SubParticles", ColumType = new ColumnType(ColumnType.ID.STRING, false, false), IsPrimarykey = false });
             SetTableName("IncAData");
 
         }

+ 20 - 20
OTSIncAMeasureApp/1-OTSMeasure/Measure/DBDataTransition/IncAFileMgr.cs

@@ -76,10 +76,10 @@ namespace OTSModelSharp
             m_generalInfoDB = GetGeneralInfoDB();
             m_generalInfoDB.Init();
 
-            m_pMergePartDB  = GetMergedParticleDB();
-            m_pMergePartDB.Init();//judge if the table exist,if exist delete firstly,then creat,else creat.
-            m_pSmallPartInfoDB = GetSmallParticleInfoDB();
-            m_pSmallPartInfoDB.Init();
+            //m_pMergePartDB  = GetMergedParticleDB();
+            //m_pMergePartDB.Init();//judge if the table exist,if exist delete firstly,then creat,else creat.
+            //m_pSmallPartInfoDB = GetSmallParticleInfoDB();
+            //m_pSmallPartInfoDB.Init();
             m_IncADataDB = GetIncADB();
             m_IncADataDB.Init();
             m_SegmentDB = GetSegmentDB();
@@ -154,17 +154,17 @@ namespace OTSModelSharp
             return System.IO.File.Exists(a_sPathFileName);
         }
 
-        public  CSmallParticleInfoDB GetSmallParticleInfoDB()
-        {
-            if (m_pSmallPartInfoDB==null)
-            {
+        //public  CSmallParticleInfoDB GetSmallParticleInfoDB()
+        //{
+        //    if (m_pSmallPartInfoDB==null)
+        //    {
               
-                    m_pSmallPartInfoDB = new CSmallParticleInfoDB(dbStore, new CSmallParticleInfoTable());
+        //            m_pSmallPartInfoDB = new CSmallParticleInfoDB(dbStore, new CSmallParticleInfoTable());
                
-            }
+        //    }
           
-            return m_pSmallPartInfoDB;
-        }
+        //    return m_pSmallPartInfoDB;
+        //}
 
         //Get DB
         public CIncADataDB GetIncADB()
@@ -185,17 +185,17 @@ namespace OTSModelSharp
             }
             return m_FieldDB; ;
         }
-        public CMergeParticleDB GetMergedParticleDB()
-        {
-            if (m_pMergePartDB==null)
-            {
+        //public CMergeParticleDB GetMergedParticleDB()
+        //{
+        //    if (m_pMergePartDB==null)
+        //    {
               
-                    m_pMergePartDB = new CMergeParticleDB(dbStore, new CMergeParticleTable());
+        //            m_pMergePartDB = new CMergeParticleDB(dbStore, new CMergeParticleTable());
               
-            }
+        //    }
 
-            return m_pMergePartDB;
-        }
+        //    return m_pMergePartDB;
+        //}
 
      public  bool Create(string a_sFileName,  bool a_bOverwrite /*= FALSE*/)
 	 {

+ 0 - 209
OTSIncAReportApp/1-UI/Control_Grids/OTSIncAReportGridsFuncation/OTSReportGridsFun.cs

@@ -1,209 +0,0 @@
-
-using OTSCLRINTERFACE;
-using OTSCommon.DBOperate.Model;
-
-using OTSIncAReportApp.SysMgrTools;
-using OTSModelSharp.ServiceCenter;
-using ServiceInterface;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-
-namespace OTSIncAReportGrids.OTSIncAReportGridsFuncation
-{
-    public class OTSReportGridsFun
-    {
-        #region 定义变量
-        //为了加快颗粒列表抠图的速度,这里保存一个全局变量
-        public List<Field> m_list_COTSFieldMgrClr = null;
-        //是否已经连接到了电镜
-        public bool m_SEMConnectionState = false;
-        //连接到电镜的ID号
-        public int m_SEM_ID = 0;
-        public HardwareController m_cfun = null;
-        #endregion
-
-        #region 构造函数
-
-        /// <summary>
-        /// 需传入,主窗体对象,与要获取数据窗体的对象
-        /// </summary>
-        /// <param name="in_frmReportApp"></param>
-        /// <param name="form"></param>
-        public OTSReportGridsFun()
-        {
-            m_cfun = HardwareController.GetSemController();//  It's better to reinitialize, but it's not good to uninitialize
-        }
-        #endregion
-
-        #region 自定义方法封装
-
-        /// <summary>
-        /// 传入颗粒的tagid和fieldid,来获取该颗粒下对应的xray数据
-        /// </summary>
-        /// <param name="in_clr_tagid"></param>
-        /// <param name="in_clr_fieldid"></param>
-        /// <param name="Search_xray"></param>
-        /// <param name="Analysis_xray"></param>
-        public void GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(int in_clr_tagid, int in_clr_fieldid, out uint[] Search_xray, out uint[] Analysis_xray, out int xray_id, out List<Element> list_celementchemistryclr)
-        {
-            Search_xray = new uint[2000];
-            Analysis_xray = new uint[2000];
-            xray_id = 0;
-            list_celementchemistryclr = new List<Element>();
-
-            //防止为空校验判断
-            if (m_list_COTSFieldMgrClr == null)
-                return;
-            Particle particle = m_list_COTSFieldMgrClr.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
-            if (particle.XrayId > -1)
-            {
-                for (int i = 0; i < 2000; i++)
-                {
-                    Analysis_xray[i] = BitConverter.ToUInt32(particle.XRayData, i * 4);
-                }
-
-                Search_xray = Analysis_xray;
-                xray_id = particle.XrayId;
-                list_celementchemistryclr = particle.ElementList;
-            }
-        }
-
-
-
-        /// <summary>
-        /// 临时创建一个用于组建particle类的小segment类结构
-        /// </summary>
-        class ShowSegment
-        {
-            Rectangle m_rect = new Rectangle();
-            List<Color> m_list_color = new List<Color>();
-
-            public Rectangle Rect
-            {
-                get { return m_rect; }
-                set { m_rect = value; }
-            }
-
-            public List<Color> List_Color
-            {
-                get { return m_list_color; }
-                set { m_list_color = value; }
-            }
-
-            /// <summary>
-            /// 传入showsegment的list对象列表,返回从该对象列表计算出的外边rect矩形[目前宽度计算错误]
-            /// </summary>
-            /// <param name="in_list_showsegment"></param>
-            /// <returns></returns>
-            public Rectangle GetRectByListRectangle(List<ShowSegment> in_list_showsegment)
-            {
-                int x = 10000, y = 10000;
-                int width = 0, height = 0;
-                for (int i = 0; i < in_list_showsegment.Count(); i++)
-                {
-                    if (x > in_list_showsegment[i].Rect.X)
-                        x = in_list_showsegment[i].Rect.X;
-                    if (y > in_list_showsegment[i].Rect.Y)
-                        y = in_list_showsegment[i].Rect.Y;
-                    if (width < in_list_showsegment[i].Rect.X + in_list_showsegment[i].Rect.Width)
-                        width = in_list_showsegment[i].Rect.X + in_list_showsegment[i].Rect.Width;
-                    if (height < in_list_showsegment[i].Rect.Height)
-                        height = in_list_showsegment[i].Rect.Height;
-                }
-                width = width - x;//计算时已增加了x在里面,计算完成后,再将x的值去掉
-
-                //height就是线的数量
-                return new Rectangle(x, y, width + 3, in_list_showsegment.Count() + 3);
-            }
-        }
-
-
-        #endregion
-
-        #region 连接电镜相关
-        /// <summary>
-        /// 连接电镜,颗粒列表使用
-        /// </summary>
-        public bool Connection_ForParticlesGrid()
-        {           
-            if (!m_SEMConnectionState)
-            {
-
-                m_SEMConnectionState = m_cfun.Connect();
-                
-            }
-
-            return m_SEMConnectionState;
-        }
-
-        /// <summary>
-        /// 移动电镜到指定的X,Y坐标上,R坐标使用原先的值进行移动
-        /// </summary>
-        /// <param name="PositionX"></param>
-        /// <param name="PositionY"></param>
-        public bool MoveSemToPointXY_ForParticlesGrid(double in_PositionX, double in_PositionY)
-        {
-            bool isSuccess = false;
-            //首先获取电镜当前的位置,并记录原R值
-            double ls_PositionX = 0;
-            double ls_PositionY = 0;
-            double ls_PositionR = 0;
-
-            if (m_SEMConnectionState)
-            {
-                isSuccess = m_cfun.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
-            }
-           
-
-            if (m_SEMConnectionState)
-            {
-                isSuccess = m_cfun.MoveSEMToPoint(new Point((int)in_PositionX, (int)in_PositionY), ls_PositionR);
-            }
-
-            return isSuccess;
-        }
-
-        /// <summary>
-        /// 设置放大倍数
-        /// </summary>
-        /// <param name="a_dMagnification"></param>
-        /// <returns></returns>
-        public bool SetMagnification(double a_dMagnification)
-        {
-            bool isSuccess = false;
-            if (m_SEMConnectionState)
-            {
-                isSuccess = m_cfun.SetMagnification(a_dMagnification);
-            }
-
-            return isSuccess;
-        }
-
-        public bool AcquireBSEImage(string sampleName, int width, int height, DwellTimeLevel dwellTime, ref byte[] ImageByte)
-        {
-            bool isSuccess = false;
-            if (m_SEMConnectionState)
-            {
-                isSuccess = m_cfun.AcquireBSEImage(sampleName, width, height, dwellTime, ref ImageByte);
-            }
-
-            return isSuccess;
-        }
-
-        public bool AcquisitionSpectrum(string samplePath, int xrayMode, double new_PixelSize, ref Particle particle, uint a_nXRayAQTime)
-        {
-            bool isSuccess = false;
-            if (m_SEMConnectionState)
-            {
-                isSuccess = m_cfun.AcquisitionSpectrum(samplePath, xrayMode, new_PixelSize, ref particle, a_nXRayAQTime);
-            }
-
-            return isSuccess;
-        }
-
-        #endregion
-    }
-}

+ 1 - 1
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ListOfSimilarParticles.cs

@@ -34,7 +34,7 @@ namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
         //记录线程是否已经运行完成的状态
         private bool m_mythread_state = false;
         //底层操作类
-        OTSReportGridsFun m_OTSIncAReportGridsFun = null;
+        SEMAndEDSOperate m_OTSIncAReportGridsFun = null;
         frmReportApp m_ReportApp;
 
 

+ 5 - 5
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ParticlesGridDevidePage.cs

@@ -38,7 +38,7 @@ namespace OTSIncAReportGrids
         public DataTable m_dt = new DataTable();
 
         //底层操作类
-        OTSReportGridsFun m_OTSIncAReportGridsFun = null;
+        SEMAndEDSOperate m_OTSIncAReportGridsFun = null;
 
         //进度条窗体
         public Frm_UserProgress m_frm_userprogress;
@@ -219,7 +219,7 @@ namespace OTSIncAReportGrids
                 lan = new Language(this);
                 table = lan.GetNameTable(this.Name);
                 m_mythread_state = false;
-                m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
+                m_mythread = new Thread(new ParameterizedThreadStart(ControlThread_GO));
                 fieldData = new FieldData(result.FilePath);
                 Particledata = new ParticleData(result.FilePath);
                 var systype = m_ReportApp.m_RptConfigFile.Systype;
@@ -237,7 +237,7 @@ namespace OTSIncAReportGrids
                     }
                 }
                 //初始化底层操作类
-                m_OTSIncAReportGridsFun = new OTSReportGridsFun();
+                m_OTSIncAReportGridsFun = new SEMAndEDSOperate();
                 return true;
             }
             catch (Exception ex)
@@ -901,7 +901,7 @@ namespace OTSIncAReportGrids
         /// <summary>
         /// 移动SEM到指定位置线程函数
         /// </summary>
-        private void Thread_GO(object in_obj)
+        private void ControlThread_GO(object in_obj)
         {
             if (m_mythread_state == false)
             {
@@ -962,7 +962,7 @@ namespace OTSIncAReportGrids
 
             if (m_mythread.ThreadState == ThreadState.Stopped)
             {
-                m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
+                m_mythread = new Thread(new ParameterizedThreadStart(ControlThread_GO));
             }
             Point point = CalculateParticleCenterPosition(result, new Point(particle.SEMPosX, particle.SEMPosY), new Point(particle.PosX, particle.PosY));
             //改为线程调用,先判断线程状态

+ 5 - 4
OTSIncAReportApp/1-UI/frmMeasureRstMgr.cs

@@ -1,4 +1,4 @@
-using Microsoft.Office.Core;
+using Microsoft.Office.Core;
 using OTS.WinFormsUI.Docking;
 using OTSCLRINTERFACE;
 using OTSCommon;
@@ -772,12 +772,13 @@ namespace OTSIncAReportApp
         {
 
             CIncAFileMgr pDBFileMgr = new CIncAFileMgr(dbfile);
-            var mergedpartdb = pDBFileMgr.GetMergedParticleDB();
-            mergedpartdb.RemoveAllRows();
+            var partdb = pDBFileMgr.GetIncADB();
+          
 
             foreach (COTSParticleClr part in mergedParts)
             {
-                mergedpartdb.SaveAParticle(part, part.GetXray(), (Point)part.GetSEMPos());
+                partdb.SaveAParticle(part, part.GetXray());
+               
             }
             CPosXrayDBMgr pXrayDBMgr = pDBFileMgr.GetPosXrayDBMgr();
             CElementChemistryDB xraydb = pXrayDBMgr.GetElementChemistryDB();

+ 2 - 2
OTSIncAReportApp/1-UI/frmReMeasure.cs

@@ -37,7 +37,7 @@ namespace OTSIncAReportApp
     {
         frmReportApp m_ReportApp;
         OTSImageDisHelp ReportFun;
-        OTSReportGridsFun m_OTSIncAReportGridsFun;
+        SEMAndEDSOperate m_OTSIncAReportGridsFun;
         List<Particle> SelectedParticles;
         List<Particle> successParticles;
         Dictionary<int, Mat> keyValuesMat;
@@ -110,7 +110,7 @@ namespace OTSIncAReportApp
 
             this.m_ReportApp = m_ReportApp;
             //初始化底层操作类
-            this.m_OTSIncAReportGridsFun = new OTSReportGridsFun();
+            this.m_OTSIncAReportGridsFun = new SEMAndEDSOperate();
             this.SelectedParticles = m_ReportApp.GetSelectedParticles();
             this.ReportFun = ReportFun;
 

+ 1 - 1
OTSIncAReportApp/OTSIncAReportApp.csproj

@@ -724,7 +724,7 @@
     <Compile Include="1-UI\Control_Grids\ElementCompositionAvgGrid.designer.cs">
       <DependentUpon>ElementCompositionAvgGrid.cs</DependentUpon>
     </Compile>
-    <Compile Include="1-UI\Control_Grids\OTSIncAReportGridsFuncation\OTSReportGridsFun.cs" />
+    <Compile Include="1-UI\Control_Grids\OTSIncAReportGridsFuncation\SEMAndEDSOperate.cs" />
     <Compile Include="1-UI\Control_Grids\ParticlesSizeGrid.cs">
       <SubType>UserControl</SubType>
     </Compile>