浏览代码

improve stage operating code.

gsp 3 年之前
父节点
当前提交
63473b8d8a

+ 14 - 13
OTSIncAMeasureApp/0-OTSModel/Measure/BSEPicData/COTSFieldData.cs

@@ -298,21 +298,22 @@ namespace OTSModelSharp
             }
 
         }
-        public bool Equals(COTSFieldData a_oSource)          // CBSEImg& operator=(const CBSEImg&);        // =operator
+        public bool PositionEquals(COTSFieldData a_oSource)          // CBSEImg& operator=(const CBSEImg&);        // =operator
         {
 
-            var xoffSet = width * m_pixelSize / 3;
-            var yoffset = height * m_pixelSize / 3;
-            if (Math.Abs(OTSPos.X - a_oSource.m_otsPos.X) < xoffSet && Math.Abs(OTSPos.Y - a_oSource.m_otsPos.Y) < yoffset)
-            {
+            //var xoffSet = width * m_pixelSize / 3;
+            //var yoffset = height * m_pixelSize / 3;
+            //if (Math.Abs(OTSPos.X - a_oSource.m_otsPos.X) < xoffSet && Math.Abs(OTSPos.Y - a_oSource.m_otsPos.Y) < yoffset)
+            //{
 
-                return true;
-            }
-            else 
-            {
-                return false;
-            
-            }
+            //    return true;
+            //}
+            //else 
+            //{
+            //    return false;
+
+            //}
+            return OTSPos.X == a_oSource.m_otsPos.X && OTSPos.Y == a_oSource.m_otsPos.Y;
            
               
         }
@@ -336,7 +337,7 @@ namespace OTSModelSharp
             return m_otsPos;
         }
 
-       public  void SetOTSPosition(System.Drawing.Point a_poiPos)
+       public  void SetOTSPosition(System.Drawing.PointF a_poiPos)
         {
             m_otsPos = a_poiPos;
         }

+ 69 - 27
OTSIncAMeasureApp/0-OTSModel/Measure/ParamData/COTSMsrPrjResultData.cs

@@ -152,27 +152,40 @@ namespace OTSModelSharp
 
                 String strIncAFilename = strFieldFileSubFolder + "\\" + SMPL_MSR_RESULT_INCLUSION_FILE;
                 //CIncAFileMgr pIncAFileMgr = new CIncAFileMgr(strIncAFilename);
-                List<COTSFieldData> allFlds = new List<COTSFieldData>();
+                List<COTSFieldData> allMeasuredFlds = new List<COTSFieldData>();
                 CMsrSampleStatus poMsrStatus = new CMsrSampleStatus();
                
                 CMsrDisplayResults poMsrResults = smpl.GetMsrResults();
                 double aFldArea = smpl.CalculateAFieldArea();
                 SetPathName(strIncAFilename);
-                if (GetAllFieldsFromDB(ref allFlds,ref poMsrStatus, poMsrResults, aFldArea))
+                if (GetAllFieldsFromDB(ref allMeasuredFlds,ref poMsrStatus, poMsrResults, aFldArea))
                 {
                   
                    
-                    var nodataFields = smpl.GetFieldsData();//there's only the field postion info.
-                    List<COTSFieldData> allflddata = new List<COTSFieldData>() ;//contains the field data that store in the database;
-                   
+                    var nodataFields = smpl.GetFieldsData();//there's only the field postion info in the xml file,so the initial filed has only postion info.
+                    List<COTSFieldData> allflddata = new List<COTSFieldData>() ;//contains all the field 
+                    //------------complete the infomation that doesn't contained in database-----
+                    int w, h;
+                    smpl.GetBSESize(out w, out h);
+                    double pixelsize = smpl.CalculatePixelSize();
+                    foreach (var f in allMeasuredFlds)
+                    {
+                        f.SetPixelSize(pixelsize);
+                        f.Width = w;
+                        f.Height = h;
+                        f.SetIsMeasureComplete(true);
+
+                    }
+                  //------------------------------
                     foreach (var emptyfld in nodataFields)
                     {
                         bool isMeasured = false;
-                        foreach (var fldwithdata in allFlds)
+                        foreach (var measuredField in allMeasuredFlds)
                         {
-                            if (fldwithdata.Equals(emptyfld))
+                            if (measuredField.PositionEquals(emptyfld))
                             {
-                                allflddata.Add(fldwithdata);
+                               
+                                allflddata.Add(measuredField);
                                 isMeasured = true;
                                 break;
                             }
@@ -269,20 +282,19 @@ namespace OTSModelSharp
 
             if (!FileExists(sDatabaseName))
             {
-
-
                 return false;
 
             }
-            List<System.Drawing.PointF> completedflds = new List<System.Drawing.PointF>();
+            List<System.Drawing.PointF> completedFldPositions = new List<System.Drawing.PointF>();
             CIncAFileMgr incAFileMgr = new CIncAFileMgr(sDatabaseName);
             var m_IncADataDB = incAFileMgr.GetIncADB();
-            m_IncADataDB.GetAllFieldsRecord(ref allFlds);
+            List<COTSFieldData> allFldsWithdata=new List<COTSFieldData>();
+            m_IncADataDB.GetAllFieldsRecord(ref allFldsWithdata);
 
             var eleChemistryDB = incAFileMgr.GetPosXrayDBMgr().GetElementChemistryDB();
              Dictionary<string, CPosXrayClr> mapXrayInfo=new Dictionary<string, CPosXrayClr>();
             eleChemistryDB.GetAllMapedXrayInfo(ref mapXrayInfo);
-            foreach (var f in allFlds)
+            foreach (var f in allFldsWithdata)
             {
                 foreach (var p in f.GetListAnalysisParticles())
                 {
@@ -306,7 +318,7 @@ namespace OTSModelSharp
             var xrayDataDBDB = incAFileMgr.GetPosXrayDBMgr().GetXrayDataDB();
             Dictionary<string, CPosXrayClr> mapXrayData=new Dictionary<string, CPosXrayClr>();// map structure:[(fieldId,xrayId),CPosXrayPtr],every element of this map represent one unique xraydata.
             xrayDataDBDB.GetAllMapedXrayData(ref mapXrayData);
-            foreach (var f in allFlds)
+            foreach (var f in allFldsWithdata)
             {
                 foreach (var p in f.GetListAnalysisParticles())
                 {
@@ -342,7 +354,7 @@ namespace OTSModelSharp
             if (SegmentDB.GetAllSegmentsRecord(mapSegments))
             {
                
-                foreach (var fld in allFlds)
+                foreach (var fld in allFldsWithdata)
                 {
                     int fldId = fld.GetId();
                     List<COTSParticleClr> parts = fld.GetListAnalysisParticles();
@@ -380,6 +392,45 @@ namespace OTSModelSharp
 
 
                 }
+            }
+
+            var fielddb = incAFileMgr.GetFieldDB();
+                var fielddata = fielddb.GetTableQueryForDataTable();
+
+                foreach (DataRow r in fielddata.Rows)
+                {
+                    var p = new Point(Convert.ToInt32(r[(int)CFieldTable.ColumnID.N_FIELDPOS_X]), Convert.ToInt32(r[(int)CFieldTable.ColumnID.N_FIELDPOS_Y]));
+                    completedFldPositions.Add(p);
+                }
+
+                status.SetCompletedFieldsCenter(completedFldPositions);
+
+
+            //add the empty field(there's no any particle in the bse image,so the field empty)
+            foreach (var p in completedFldPositions)
+            {
+                bool haveData=false;
+                var emptyFld = new COTSFieldData();
+                emptyFld.SetOTSPosition(p);
+                foreach (var fld in allFldsWithdata)
+                {
+                    
+                    if (fld.PositionEquals(emptyFld))
+                    {
+                        haveData = true;
+                        allFlds.Add(fld);
+                        break;
+                    }
+                
+                }
+                if (!haveData)
+                {
+                    allFlds.Add(emptyFld);
+                }
+            
+            
+            }
+
                 // get MsrStatus info from DB.
                 var m_GenInfoDB = incAFileMgr.GetGeneralInfoDB();//DBStoreFile类
                 String strTimeStart = "";
@@ -389,16 +440,7 @@ namespace OTSModelSharp
                 m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeStart(), ref strTimeStart);
                 m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeEnd(), ref strTimeEnd);
                 m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameResultStatus(), ref strRstStatus);
-                var fielddb = incAFileMgr.GetFieldDB();
-                var fielddata = fielddb.GetTableQueryForDataTable();
-
-                foreach (DataRow r in fielddata.Rows)
-                {
-                    var p = new Point(Convert.ToInt32( r[(int)CFieldTable.ColumnID.N_FIELDPOS_X]),Convert.ToInt32( r[(int)CFieldTable.ColumnID.N_FIELDPOS_Y]));
-                    completedflds.Add(p);
-                }
-
-                status.SetCompletedFieldsCenter(completedflds);
+               
               
 
                 DateTime timeStart, timeEnd;
@@ -442,8 +484,8 @@ namespace OTSModelSharp
                 rst.SetMeasuredArea(Convert.ToUInt64(msrFldsArea * 1000000));
                 rst.SetRatio(allPartArea / (msrFldsArea * 1000000));
                 return true;
-            }
-            return false;
+            
+            //return false;
         }
 
         string ConvertFormatOfDateString(string Time)

+ 3 - 16
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSSample.cs

@@ -422,21 +422,12 @@ namespace OTSDataType
         public void SetFieldsData(List<COTSFieldData> a_listFieldData)
         {
             m_listFieldData = a_listFieldData;
-        }
-        public COTSFieldData GetFieldDataByOTSPos(PointF otsPos)
-        {
-            foreach (var f in m_listFieldData)
+            for (int i = 0; i < m_listFieldData.Count; i++)
             {
-                if (f.Equals(otsPos))
-                {
-                    return f;
-                
-                }
-            
+                m_listFieldData[i].SetId(i);
             }
-
-            return null;
         }
+       
         public void AddFieldData(PointF centerPoint )
 
         {
@@ -462,9 +453,6 @@ namespace OTSDataType
             // new field id
             int nNewFieldId = listFieldData.Count;
 
-
-
-            bool bUnit = false;
             do
             {
                 bool iffound = false;
@@ -817,7 +805,6 @@ namespace OTSDataType
                         {
                             return false;
                         }
-                        //m_poMsrParams.GetXRayParam().SetXRaySearchCount(a_nValue);
                     }
                     break;
 

+ 2 - 6
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -333,6 +333,7 @@ namespace OTSMeasureApp
         
             m_visualStage.InitSampleStageData(SStage, SEMStageData, this.Width, this.Height);
             m_visualStage.DrawSampleStage();
+            m_visualSamples.Clear();
             foreach (var SMeasrueArea in SMeasrueParaList)
             {
                 var m_Sample = m_MeasureAppForm.m_ProjParam.GetResultData().GetSampleByName(SMeasrueArea.sSampleName);
@@ -412,8 +413,6 @@ namespace OTSMeasureApp
                                 CRectangleGDIObject createRect = new CRectangleGDIObject(visualRect,(int)fld.GetOTSPosition().X,(int)fld.GetOTSPosition().Y,  CreateRectangleType.FieldRectangle, sampleHoleName, sampleName, ColorTranslator.FromHtml(ColorStr));
 
                                 visualfieldRects.Add(createRect);
-
-
                            
                             }
 
@@ -1102,15 +1101,12 @@ namespace OTSMeasureApp
                         }
                     }
 
-                  
 
                     polygonPoints.Add(m_MouseDownPoint);
 
 
                     m_DrawMeasureGDIObject.SetPolygonPointFList(polygonPoints);
-                  
-
-   
+     
                     return;
                 }
                 else if(m_DrawMeasureType == CreateRectangleType.CircleByThreePoints)

+ 1 - 1
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -1201,7 +1201,7 @@ namespace OTSMeasureApp
             bool bOpenFlag=false;
             COTSMsrPrjResultData ProjDataMgr = new COTSMsrPrjResultData();
             string strPathName;
-            //strPathName.Trim();
+         
           
                 // file open dialog
                 OpenFileDialog openFileDialog = new OpenFileDialog();