OTSSamplespaceWindow.cs 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using OTS.WinFormsUI.Docking;
  6. using System.Collections;
  7. using OTSDataType;
  8. using OTSModelSharp;
  9. using MyControls;
  10. using OTSModelSharp.ServiceInterface;
  11. using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel;
  12. using static OTSDataType.otsdataconst;
  13. namespace OTSMeasureApp
  14. {
  15. public enum EnumMousePointPosition
  16. {
  17. MouseSizeNone = 0, //'无
  18. MouseSizeRight = 1, //'拉伸右边框
  19. MouseSizeLeft = 2, //'拉伸左边框
  20. MouseSizeBottom = 3, //'拉伸下边框
  21. MouseSizeTop = 4, //'拉伸上边框
  22. MouseSizeTopLeft = 5, //'拉伸左上角
  23. MouseSizeTopRight = 6, //'拉伸右上角
  24. MouseSizeBottomLeft = 7, //'拉伸左下角
  25. MouseSizeBottomRight = 8, //'拉伸右下角
  26. MouseDrag = 9 // '鼠标拖动
  27. }
  28. public partial class OTSSamplespaceWindow : DockContent
  29. {
  30. #region 全局变量定义
  31. public CVisualStage m_visualStage;
  32. //样品孔的List集合
  33. string m_SampleHoleSelectName = string.Empty;
  34. public string m_SampleSelectName = string.Empty;
  35. public List<CVisualSampleArea> m_visualSamples;
  36. //BSE图像
  37. public static List<CRectangleGDIObject> m_ImageGDIObjects;
  38. //BSE图像帧图 为了获取位置与尺寸
  39. public static List<CRectangleGDIObject> m_ImageOfFieldGDIObjects;
  40. //手绘测量区域
  41. public static CRectangleGDIObject m_DrawMeasureGDIObject=new CRectangleGDIObject();
  42. //多边形测量区域完成标识
  43. public static CRectangleGDIObject m_DrawPolygonFinishGDIObject;
  44. //主窗体对象
  45. OTSIncAMeasureAppForm m_MeasureAppForm;
  46. SEMDATAFieldManage m_SEMDATAFieldManage;
  47. private _5_OTSMeasureStatuImageFun.SlopFocus slopFocus=null;
  48. const float m_PenWidth = 5;
  49. const int m_MinMeasureWidthValue = 20;
  50. //点数量
  51. const int m_PolygonMinPointCount = 2;
  52. //与多边形绘制的开始点相差的像素值
  53. const int m_OffsetPX = 10;
  54. //默认值
  55. const int m_DValue = 1;
  56. #region 手动绘制测量区域
  57. Point m_MouseDownPoint;
  58. Point m_MouseMovePoint;
  59. //手动绘制多边形测量区域完成标识
  60. bool m_IsDrawPolygonFinish = false;
  61. //手动绘制测量区域的形状类型
  62. CreateRectangleType m_DrawMeasureType = (CreateRectangleType)1;
  63. //是否手绘标识
  64. bool m_IsDrawMeasure = false;
  65. #endregion
  66. #endregion
  67. NLog.Logger log;
  68. #region 标尺变量
  69. //最小缩放倍数
  70. const float f_zoom_mix = 0.5f;
  71. //标尺的大小记录
  72. private float f_ruler_size = 100;
  73. //标尺原先大小的记录,参与计算
  74. private float f_old_ruler_size = 100;
  75. #endregion
  76. //国际化
  77. OTSCommon.Language lan;
  78. Hashtable table;
  79. #region 设置双缓冲
  80. /// <summary>
  81. /// 设置双缓冲
  82. /// </summary>
  83. public void SetDoubleBufferByIsDraw()
  84. {
  85. SetStyle(ControlStyles.UserPaint, true);
  86. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
  87. this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 双缓冲
  88. }
  89. #endregion
  90. #region 构造函数 获取父窗体对象
  91. public OTSSamplespaceWindow(OTSIncAMeasureAppForm MeasureAppForm)
  92. {
  93. InitializeComponent();
  94. m_MeasureAppForm = MeasureAppForm;
  95. SetDoubleBufferByIsDraw();// 双缓冲
  96. //国际化
  97. lan = new OTSCommon.Language(this);
  98. table = lan.GetNameTable(this.Name);
  99. }
  100. /// <summary>
  101. /// 画圆形测试区域 事件
  102. /// </summary>
  103. public void DrawCircleMeasure()
  104. {
  105. //手绘测量区域类型为圆形
  106. m_DrawMeasureType = CreateRectangleType.Circle;
  107. m_IsDrawMeasure = true;
  108. this.Cursor = Cursors.Hand;
  109. }
  110. /// <summary>
  111. /// 画矩形测试区域 事件
  112. /// </summary>
  113. public void DrawRectangleMeasure()
  114. {
  115. //手绘测量区域类型为矩形
  116. m_DrawMeasureType = CreateRectangleType.SampleBackGround_Rectangle;
  117. m_IsDrawMeasure = true;
  118. this.Cursor = Cursors.Hand;
  119. }
  120. /// <summary>
  121. /// 画多边形测试区域 事件
  122. /// </summary>
  123. public void DrawPolygonMeasure()
  124. {
  125. m_DrawMeasureType = CreateRectangleType.Polygon;
  126. m_IsDrawMeasure = true;
  127. this.Cursor = Cursors.Hand;
  128. }
  129. /// <summary>
  130. /// 三点画圆形测试区域 事件 先多边形后圆形
  131. /// </summary>
  132. public void DrawCircleMeasureByThreePoints()
  133. {
  134. //手绘测量区域类型为圆形
  135. m_DrawMeasureType = CreateRectangleType.CircleByThreePoints;
  136. m_IsDrawMeasure = true;
  137. this.Cursor = Cursors.Hand;
  138. }
  139. public void DrawRingShapeArea()
  140. {
  141. //手绘测量区域类型为圆形
  142. m_DrawMeasureType = CreateRectangleType.RingShape;
  143. RingGdiDataInput frmInput = new RingGdiDataInput();
  144. if (frmInput.ShowDialog() == DialogResult.OK)
  145. {
  146. float diameter =(float) m_visualStage.MicronConvertToPixel(frmInput.Diameter);
  147. float ringwidth = (float)m_visualStage.MicronConvertToPixel( frmInput.RingWidth);
  148. var sam = GetWorkingVisualSample();
  149. SizeF size = new SizeF(diameter, diameter);
  150. var position =sam.GetMeasureGDIObject().GetZoomedRegionF().Location;
  151. RectangleF rectangle = new RectangleF(position, size);
  152. Color MeasureColor = Color.Red;
  153. CRingGDIObject newGDI;
  154. newGDI = new CRingGDIObject(rectangle, CreateRectangleType.RingShape, sam.GetSampleGDIObject().NameOrHoleName, sam.GetSampleName(), MeasureColor);
  155. newGDI.SetRingWidth(ringwidth);
  156. newGDI.SetZoomNumber(m_visualStage.GetZoomNum());
  157. newGDI.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
  158. newGDI.IsWorkSample = true;
  159. sam.SetMeasureGDIObject(newGDI);
  160. m_DrawPolygonFinishGDIObject = null;
  161. m_DrawMeasureGDIObject = null;
  162. var para = m_visualStage.GetSampleMeasurePara(sam.GetMeasureGDIObject());
  163. m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);
  164. }
  165. }
  166. #region 菜单操作
  167. private void CMStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  168. {
  169. Point mousePoint = this.PointToClient(Control.MousePosition);
  170. CMStrip.Hide();
  171. switch (e.ClickedItem.Name)
  172. {
  173. case "AddStage":
  174. m_MeasureAppForm.m_SPropertyWindows.TSSaveAs.Enabled = true;
  175. m_MeasureAppForm.m_SPropertyWindows.TSLoad.Enabled = true;
  176. m_MeasureAppForm.m_SPropertyWindows.TSEdit.Enabled = false;
  177. m_MeasureAppForm.m_SPropertyWindows.TSEdit.Visible = false;
  178. //添加样品
  179. m_MeasureAppForm.AddNewSampleMeasure(m_SampleHoleSelectName);
  180. break;
  181. case "DeleteStage":
  182. //删除样品
  183. DeleteSampleInfo(m_SampleSelectName);
  184. break;
  185. case "DriveSEMToCenterLocation":
  186. //驱动SEM到中心位置
  187. SetSEMToCenterPoint();
  188. ReadSEMDataAndSetToCurrentSample();
  189. PrepareMeasureField(GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
  190. break;
  191. case "DriveSEMToCurrentLocation":
  192. //驱动SEM到当前位置
  193. SetSEMCurrentLocation();
  194. ReadSEMDataAndSetToCurrentSample();
  195. PrepareMeasureField(GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
  196. break;
  197. case "SetSEMCenterLocation":
  198. //将测量区域移到SEM当前位置
  199. SetMeasureToSEMLocation();
  200. ReadSEMDataAndSetToCurrentSample();
  201. PrepareMeasureField(GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
  202. break;
  203. case "ReadSEMData":
  204. m_MeasureAppForm.SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  205. ReadSEMDataAndSetToCurrentSample();
  206. PrepareMeasureField(GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
  207. break;
  208. case "SetSemData":
  209. double SemMag = 0;
  210. double dDistance = 0;
  211. if (m_MeasureAppForm.m_ProjParam.GetMagAndDistance(ref SemMag, ref dDistance))
  212. {
  213. //设置SEM数据
  214. if (!SetSEMDATAMParameter(SemMag, dDistance))
  215. {
  216. log.Error("Failed SetSemData:--Mag:" + SemMag + "--Distance:" + dDistance + "--");
  217. }
  218. }
  219. break;
  220. case "ShootBSEPicture":
  221. //设置消息类型 拍摄样品孔
  222. m_MeasureAppForm.SetRunType(MSR_RUN_TYPE.RUNSampleHoleImage);
  223. //清除原图片信息
  224. DeleteHoleBSEImageDataNoMessageBox();
  225. PrepareMeasureField(GetWorkingVisualSample(), MSR_RUN_TYPE.RUNSampleHoleImage);
  226. GetBSEPictures();
  227. break;
  228. case "DeleteBSEPicture":
  229. DeleteHoleBSEImageDataNoMessageBox();
  230. break;
  231. case "SlopFocusMenuItem":
  232. if (slopFocus == null)
  233. {
  234. slopFocus = new _5_OTSMeasureStatuImageFun.SlopFocus(this);
  235. }
  236. slopFocus.Show();
  237. break;
  238. }
  239. }
  240. #endregion
  241. public CVisualSampleArea GetWorkingVisualSample()
  242. {
  243. foreach (var s in m_visualSamples)
  244. {
  245. if (s.IsWorkSample())
  246. {
  247. return s;
  248. }
  249. }
  250. return null;
  251. }
  252. public CVisualSampleArea GetVisualSampleByName(string name)
  253. {
  254. foreach (var s in m_visualSamples)
  255. {
  256. if (s.GetSampleName() == name)
  257. {
  258. return s;
  259. }
  260. }
  261. return null;
  262. }
  263. public void OpenExistSampleFile(CStage SStage, CSEMStageData SEMStageData, List<SampleMeasurePara> SMeasrueParaList)
  264. {
  265. m_visualStage.clear();
  266. m_visualStage.InitSampleStageData(SStage, SEMStageData, this.Width, this.Height);
  267. m_visualStage.DrawSampleStage();
  268. m_visualSamples.Clear();
  269. foreach (var SMeasrueArea in SMeasrueParaList)
  270. {
  271. var m_Sample = m_MeasureAppForm.m_ProjParam.GetResultData().GetSampleByName(SMeasrueArea.sSampleName);
  272. var FldDatas = m_Sample.GetFieldsData();
  273. if (FldDatas.Count == 0)
  274. {
  275. //this part code is to be compatible with previouse version result file which there's no AllField position info.
  276. DrawSampleAndMeasureInfo(SMeasrueArea);
  277. }
  278. else
  279. {
  280. var item = m_visualStage.GetHoleGDIByHoleName(SMeasrueArea.sampleHoleName);
  281. if (item != null)
  282. {
  283. CVisualSampleArea sam;
  284. if (AddVisualSample(SMeasrueArea.sampleHoleName, SMeasrueArea.sSampleName, out sam))
  285. {
  286. if (SMeasrueArea.iShape == (ShapeType)CreateRectangleType.Polygon)
  287. {
  288. var ps = new List<PointF>();
  289. foreach (var p in SMeasrueArea.DrawPolygonPointList)
  290. {
  291. var ctrlcoordPoint = m_visualStage.OTSCoordToCtrlCoord(p);
  292. ps.Add(ctrlcoordPoint);
  293. }
  294. CRectangleGDIObject polygonGdi = new CRectangleGDIObject(ps, CreateRectangleType.Polygon, (ShapeType)SMeasrueArea.iShape, SMeasrueArea.sampleHoleName, SMeasrueArea.sSampleName, Color.Red);
  295. sam.SetMeasureGDIObject(polygonGdi);
  296. }
  297. else
  298. {
  299. PointF xHole = new PointF(SMeasrueArea.MeasureRect.Left, SMeasrueArea.MeasureRect.Top);
  300. PointF yHole = new PointF(SMeasrueArea.MeasureRect.Right, SMeasrueArea.MeasureRect.Bottom);
  301. CRectangleGDIObject gdi = m_visualStage.GetCtrlCoordRect(xHole, yHole, (CreateRectangleType)SMeasrueArea.iShape, "", "");
  302. gdi.SampleName = SMeasrueArea.sSampleName;
  303. gdi.NameOrHoleName = SMeasrueArea.sampleHoleName;
  304. gdi.Shape = SMeasrueArea.iShape;
  305. CRectangleGDIObject measureGdi;
  306. if (m_visualStage.GetMeasureGdiObjectFromSampleGdi(gdi, out measureGdi))
  307. {
  308. sam.SetMeasureGDIObject(measureGdi);
  309. }
  310. }
  311. List<CRectangleGDIObject> visualfieldRects = new List<CRectangleGDIObject>();
  312. foreach (var fld in FldDatas)
  313. {
  314. float micronWidth = (float)fld.Width * (float)fld.GetPixelSize();
  315. float micronHeight = (float)fld.Height * (float)fld.GetPixelSize();
  316. var fldRect = new RectangleF(new PointF(fld.GetOTSPosition().X - micronWidth / 2, fld.GetOTSPosition().Y - micronHeight / 2), new SizeF(micronWidth, micronHeight));
  317. PointF lt = new PointF(fldRect.Left, fldRect.Top);
  318. PointF rb = new PointF(fldRect.Right, fldRect.Bottom);
  319. RectangleF visualRect = m_visualStage.GetCtrlCoordRectF(lt, rb);
  320. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SingleColor);
  321. string sampleName = sam.GetSampleName();
  322. string sampleHoleName = sam.GetSampleGDIObject().NameOrHoleName;
  323. CRectangleGDIObject createRect = new CRectangleGDIObject(visualRect,(int)fld.GetOTSPosition().X,(int)fld.GetOTSPosition().Y, CreateRectangleType.FieldRectangle, sampleHoleName, sampleName, ColorTranslator.FromHtml(ColorStr));
  324. visualfieldRects.Add(createRect);
  325. }
  326. sam.GetMeasureGDIObject().SubItems().Clear();
  327. //添加帧图列表
  328. int sequenceNum = 0;
  329. foreach (var r in visualfieldRects)
  330. {
  331. if (sam.GetMeasureGDIObject().ifRectangleIntersect(r))//filter the unmeasure fields
  332. {
  333. r.SequenceNum = sequenceNum++;
  334. sam.AddFieldGDIObject(r);
  335. }
  336. }
  337. COTSMsrPrjResultData cProjMgr = m_MeasureAppForm.m_ProjParam.GetResultData();
  338. List<PointF> CompleteFieldList = cProjMgr.GetSampleByName(SMeasrueArea.sSampleName).GetMsrStatus().GetCompletedFieldsCenter();
  339. if (CompleteFieldList.Count > 0)
  340. {
  341. ChangeCompleteFieldMeasureState(CompleteFieldList, Color.Green, sam);
  342. }
  343. }
  344. }
  345. }
  346. }
  347. SwitchWorkSample(SMeasrueParaList[0].sSampleName);
  348. m_SampleSelectName = SMeasrueParaList[0].sSampleName;
  349. //重新绘制
  350. Invalidate();
  351. }
  352. public void SwitchWorkSample(string sNewWSampleName, bool bDrawField = false)
  353. {
  354. try
  355. {
  356. for (int i = 0; i < m_visualSamples.Count; i++)
  357. {
  358. //获取颜色
  359. if (m_visualSamples[i].GetSampleName() == sNewWSampleName)
  360. {
  361. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
  362. m_visualSamples[i].GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(ColorStr);
  363. m_visualSamples[i].SetIsWorkSample(true);
  364. }
  365. else
  366. {
  367. string SampleColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor);
  368. m_visualSamples[i].GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(SampleColorStr);
  369. m_visualSamples[i].SetIsWorkSample(false);
  370. }
  371. }
  372. m_IsDrawMeasure = false;
  373. this.Invalidate();
  374. return;
  375. }
  376. catch (Exception ex)
  377. {
  378. log.Trace(ex.ToString() );
  379. }
  380. }
  381. public void ChangeCompleteFieldMeasureState(List<PointF> CompleteFieldList, Color changeColor,CVisualSampleArea vsSam)
  382. {
  383. foreach(var p in CompleteFieldList)
  384. {
  385. ChangeDoneMeasureState(vsSam,p, changeColor);
  386. }
  387. }
  388. public void ChangeDoneMeasureState(CVisualSampleArea vsSam, PointF CurrentFIELDOTSPoint, Color changeColor)
  389. {
  390. foreach (var gdi in vsSam.GetMeasureFieldGDIObjects())
  391. {
  392. var fieldPoint = m_visualStage.OTSCoordToCtrlCoord(new PointF((float)CurrentFIELDOTSPoint.X , (float)CurrentFIELDOTSPoint.Y));
  393. if (gdi.IfContains(fieldPoint))
  394. {
  395. //修改完成状态
  396. gdi.SelColor = changeColor;
  397. break;
  398. }
  399. }
  400. }
  401. public void ChangeWorkSampleName(string sNewWSampleName)
  402. {
  403. //更换样品名称
  404. var sam = GetWorkingVisualSample();
  405. sam.SetSampleName(sNewWSampleName);
  406. this.Invalidate();
  407. return;
  408. }
  409. public void SetMeasureState(Color setColor)
  410. {
  411. foreach (var items in m_visualSamples)
  412. {
  413. items.GetMeasureGDIObject().SelColor = setColor;
  414. }
  415. }
  416. #endregion
  417. public void SetSampleState(Color setColor)
  418. {
  419. foreach (var items in m_visualSamples)
  420. {
  421. if (items.GetSampleGDIObject().IsDragging)
  422. {
  423. //设置颜色
  424. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
  425. items.GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(ColorStr);
  426. }
  427. else
  428. {
  429. items.GetSampleGDIObject().SelColor = setColor;
  430. }
  431. }
  432. }
  433. public bool DeleteSample(string SampleName)
  434. {
  435. var sam = GetVisualSampleByName(SampleName);
  436. m_visualStage.DecreaseSampleCount(SampleName);
  437. m_visualSamples.Remove(sam);
  438. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor);
  439. SetSampleState(ColorTranslator.FromHtml(ColorStr));
  440. SetMeasureState(ColorTranslator.FromHtml(ColorStr));
  441. return false;
  442. }
  443. public void DeleteWorkSample(string sDeleteWSampleName)
  444. {
  445. try
  446. {
  447. DeleteSample(sDeleteWSampleName);
  448. }
  449. catch (Exception ex)
  450. {
  451. log.Error( ex.ToString() );
  452. }
  453. }
  454. #region 更改工作样品中 测量区域形状
  455. public void changeShape(ShapeType iShape)
  456. {
  457. try
  458. {
  459. string sampleName = m_MeasureAppForm.m_ProjParam.GetWorkSampleName();
  460. //m_Shap 更换样品形状
  461. var sam = GetWorkingVisualSample();
  462. var itemMeasure = sam.GetMeasureGDIObject();
  463. itemMeasure.Shape = iShape;
  464. var sampleMeasurePara = m_visualStage. GetSampleMeasurePara(sam.GetMeasureGDIObject());
  465. m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(sampleMeasurePara);
  466. PrepareMeasureField(sam, m_MeasureAppForm.GetRunType());
  467. this.Invalidate();
  468. return;
  469. }
  470. catch (Exception ex)
  471. {
  472. log.Error(ex.ToString() );
  473. }
  474. }
  475. #endregion
  476. public void AddSampleArea(SampleMeasurePara SMeasurePara)
  477. {
  478. try
  479. {
  480. CMStrip.Hide();
  481. CVisualSampleArea sam;
  482. //添加样品
  483. foreach (var itemSample in m_visualSamples)
  484. {
  485. //设置颜色
  486. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor);
  487. itemSample.GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(ColorStr);
  488. itemSample.SetIsWorkSample(false);
  489. }
  490. if (m_visualStage. GetVisualSampleArea(SMeasurePara, out sam))
  491. {
  492. sam.SetIsWorkSample(true);
  493. m_visualSamples.Add(sam);
  494. m_SampleSelectName = SMeasurePara.sSampleName;
  495. var para = m_visualStage.GetSampleMeasurePara(sam.GetMeasureGDIObject());
  496. //var para = SMeasurePara;
  497. m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);
  498. Invalidate();
  499. }
  500. }
  501. catch (Exception ex)
  502. {
  503. log.Error( ex.ToString() );
  504. }
  505. }
  506. public bool AddVisualSample(string SampleHoleName, string SampleName,out CVisualSampleArea outsample)
  507. {
  508. CRectangleGDIObject itemAdd;
  509. //设置样品选择状态为非工作样品
  510. foreach (var Sample in m_visualSamples)
  511. {
  512. var itemSample = Sample.GetSampleGDIObject();
  513. //设置颜色
  514. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor);
  515. itemSample.SelColor = ColorTranslator.FromHtml(ColorStr);
  516. itemSample.IsWorkSample = false;
  517. }
  518. itemAdd = m_visualStage.GetHoleGDIByHoleName(SampleHoleName);
  519. if (itemAdd != null)
  520. {
  521. //获取样品台类型
  522. var shape = itemAdd.Shape;
  523. //设置颜色
  524. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
  525. Color selColor = ColorTranslator.FromHtml(ColorStr);
  526. CRectangleGDIObject sample =new CRectangleGDIObject (itemAdd.GetOrigionalDrawRegionF(), CreateRectangleType.SelectSample, shape, itemAdd.NameOrHoleName, selColor);
  527. //累加样品数量
  528. itemAdd.SampleCount += 1;
  529. itemAdd.IsWorkSample = true;
  530. sample.SampleName = SampleName;
  531. sample.NameOrHoleName = itemAdd.NameOrHoleName;
  532. var newSam = new CVisualSampleArea();
  533. newSam.SetSampleGDIObject(sample);
  534. newSam.SetSampleName(sample.SampleName);
  535. m_visualSamples.Add(newSam);
  536. outsample = newSam;
  537. return true;
  538. }
  539. outsample = null;
  540. return false;
  541. }
  542. #region 设置工作样品
  543. /// <summary>
  544. /// 设置工作样品与测量区域
  545. /// </summary>
  546. /// <param name="sampleName">样品名称</param>
  547. public void SetSampleOrder(string sampleName)
  548. {
  549. //修改测量区域集合 索引 (添加样品或者切换样品时,将当前工作样品显示在样品孔的最上)
  550. m_visualSamples = SelectMeasureIndexIsTop(m_visualSamples, sampleName);
  551. }
  552. #endregion
  553. private List<CVisualSampleArea> SelectMeasureIndexIsTop(List<CVisualSampleArea> objList, string SampleName)
  554. {
  555. List<CVisualSampleArea> objListTemp = objList;
  556. CVisualSampleArea itemTemp ;
  557. foreach (CVisualSampleArea item in objList)
  558. {
  559. if (item.GetSampleName() == SampleName)
  560. {
  561. //临时记录所选测量区域
  562. itemTemp = item;
  563. //删除原信息
  564. objListTemp.Remove(item);
  565. //添加新信息
  566. objListTemp.Insert(objListTemp.Count, itemTemp);
  567. break;
  568. }
  569. }
  570. return objListTemp;
  571. }
  572. //响应委托事件的样品台数据
  573. public void InitStageDisplay(CStage SStage, CSEMStageData SEMStageData)
  574. {
  575. m_visualStage. InitSampleStageData(SStage, SEMStageData,this.Width,this.Height);
  576. //清除所有绘制的图形信息
  577. ClearDrawInfo();
  578. //绘制样品台信息
  579. m_visualStage. DrawSampleStage();
  580. //标尺初始化
  581. RulerInit(m_visualStage.GetOTSSampleStageData());
  582. ShowRulerLocation();
  583. //图像隐藏
  584. HideMessureStatuWindowBSEImage(m_MeasureAppForm);
  585. //将测量结果信息状态初始化
  586. InitMeasureStateInfo();
  587. if (m_visualSamples.Count == 0)
  588. {
  589. //将测量状态初始化
  590. m_MeasureAppForm.m_MessureStatuWindow.SetMeasureStatusInit();
  591. }
  592. Invalidate();
  593. }
  594. public void HideMessureStatuWindowBSEImage(OTSIncAMeasureAppForm m_MeasureApps)
  595. {
  596. m_MeasureApps.m_MessureStatuWindow.pbBSEImage.Hide();
  597. }
  598. #region 将测量状态进度窗口信息初始化
  599. public void InitMeasureStateInfo()
  600. {
  601. m_MeasureAppForm.m_MeasureRetWindow.SetInit();
  602. }
  603. #endregion
  604. private void GetTriangleExcenterRadius(PointF px1, PointF px2, PointF px3, out float R, out PointF center)
  605. {
  606. float x1, y1, x2, y2, x3, y3;
  607. float a, b;
  608. x1 = px1.X;
  609. y1 = px1.Y;
  610. x2 = px2.X;
  611. y2 = px2.Y;
  612. x3 = px3.X;
  613. y3 = px3.Y;
  614. a = ((y2 - y1) * (y3 * y3 - y1 * y1 + x3 * x3 - x1 * x1) - (y3 - y1) * (y2 * y2 - y1 * y1 + x2 * x2 - x1 * x1)) / (2 * ((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)));
  615. b = ((x2 - x1) * (x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1) - (x3 - x1) * (x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1)) / (2 * ((y3 - y1) * (x2 - x1) - (y2 - y1) * (x3 - x1)));
  616. center = new PointF(a, b);
  617. R = (float)Math.Sqrt((x1 - a) * (x1 - a) + (y1 - b) * (y1 - b));
  618. }
  619. #region 窗体事件
  620. private void OTSSamplespaceWindow_Load(object sender, EventArgs e)
  621. {
  622. m_visualStage = new CVisualStage();
  623. m_visualSamples = new List<CVisualSampleArea>();
  624. //样品孔BSE图像
  625. m_ImageGDIObjects = new List<CRectangleGDIObject>();
  626. //BSE图像帧图为了获取位置与尺寸
  627. m_ImageOfFieldGDIObjects = new List<CRectangleGDIObject>();
  628. this.ResizeRedraw = true;
  629. control_Ruler2 = new Control_Ruler();
  630. Point rulerLocation = new Point(10, this.Height - (int)(control_Ruler2.Height * 2));
  631. control_Ruler2.Location = rulerLocation;
  632. this.Controls.Add(control_Ruler2);
  633. log = NLog.LogManager.GetCurrentClassLogger();
  634. }
  635. public static void SetShowCMStrip(ContextMenuType IsSelectType, ContextMenuStrip cmStrip, bool IsTrue)
  636. {
  637. switch (IsSelectType)
  638. {
  639. case ContextMenuType.SampleHoleMenu:
  640. cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true;
  641. cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = false;
  642. cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = false;
  643. cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = false;
  644. cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = false;
  645. cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = false;
  646. cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true;
  647. cmStrip.Items[(int)MenuIndex.SEMStripSeparator].Enabled = false;
  648. cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = false;
  649. cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = false;
  650. cmStrip.Items[(int)MenuIndex.SlopFocus].Enabled = false;
  651. break;
  652. case ContextMenuType.SampleMenu:
  653. cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true;
  654. cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = true;
  655. cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = true;
  656. cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = false;
  657. cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = false;
  658. cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = false;
  659. cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true;
  660. cmStrip.Items[(int)MenuIndex.SEMStripSeparator].Enabled = false;
  661. cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = true;
  662. cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = false;
  663. cmStrip.Items[(int)MenuIndex.SlopFocus].Enabled = true;
  664. break;
  665. case ContextMenuType.MeasureMenu:
  666. cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true;
  667. cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = true;
  668. cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = true;
  669. cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = true;
  670. cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = true;
  671. cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = IsTrue;
  672. cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true;
  673. cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = true;
  674. cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = true;
  675. cmStrip.Items[(int)MenuIndex.SlopFocus].Enabled = true;
  676. break;
  677. case ContextMenuType.FieldMenu:
  678. cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true;
  679. cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = true;
  680. cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = true;
  681. cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = true;
  682. cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = true;
  683. cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = true;
  684. cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true;
  685. cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = true;
  686. cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = true;
  687. cmStrip.Items[(int)MenuIndex.SlopFocus].Enabled = true;
  688. break;
  689. case ContextMenuType.ThreadRunMenu:
  690. for (int i = 0; i < cmStrip.Items.Count; i++)
  691. {
  692. cmStrip.Items[i].Enabled = false;
  693. }
  694. break;
  695. case ContextMenuType.SampleStateMenu:
  696. cmStrip.Items[(int)MenuIndex.AddSample].Enabled = false;
  697. cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = false;
  698. cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = false;
  699. cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = false;
  700. cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = IsTrue;
  701. cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = IsTrue;
  702. cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true;
  703. cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = false;
  704. cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = false;
  705. cmStrip.Items[(int)MenuIndex.SlopFocus].Enabled = false;
  706. break;
  707. case ContextMenuType.SampleHoleBSEImage:
  708. cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true;
  709. cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = IsTrue;
  710. cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = IsTrue;
  711. cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = IsTrue;
  712. cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = IsTrue;
  713. cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = IsTrue;
  714. cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true;
  715. cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = IsTrue;
  716. cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = true;
  717. cmStrip.Items[(int)MenuIndex.SlopFocus].Enabled = IsTrue;
  718. break;
  719. }
  720. }
  721. private List<CRectangleGDIObject> GetAllVisualSampleGDIObject()
  722. {
  723. List<CRectangleGDIObject> allobj = new List<CRectangleGDIObject>();
  724. foreach (var s in m_visualSamples)
  725. {
  726. allobj.Add(s.GetSampleGDIObject());
  727. allobj.Add(s.GetMeasureGDIObject());
  728. foreach (var f in s.GetMeasureFieldGDIObjects())
  729. {
  730. allobj.Add(f);
  731. }
  732. }
  733. return allobj;
  734. }
  735. private List<CRectangleGDIObject> GetOnlyVisualSampleGDIObject()
  736. {
  737. List<CRectangleGDIObject> allobj = new List<CRectangleGDIObject>();
  738. foreach (var s in m_visualSamples)
  739. {
  740. allobj.Add(s.GetSampleGDIObject());
  741. }
  742. return allobj;
  743. }
  744. private List<CRectangleGDIObject> GetAllVisualFieldGdiObject()
  745. {
  746. List<CRectangleGDIObject> allobj = new List<CRectangleGDIObject>();
  747. foreach (var s in m_visualSamples)
  748. {
  749. allobj.Add(s.GetMeasureGDIObject());
  750. var flds = s.GetMeasureFieldGDIObjects();
  751. for(int i=flds.Count;i>0;i--)//revert the sequence so that the last field will paint first.then the green or yellow rectangle can display fully.
  752. {
  753. var f = flds[i-1];
  754. allobj.Add(f);
  755. }
  756. }
  757. return allobj;
  758. }
  759. private EnumMousePointPosition MousePointPosition(Point point, Point e)
  760. {
  761. //MouseDrag 中心
  762. if ((e.X == point.X) && (e.Y == point.Y))
  763. {
  764. return EnumMousePointPosition.MouseDrag;
  765. }
  766. //MouseSizeTopLeft 上左
  767. if ((e.X < point.X) && (e.Y < point.Y))
  768. {
  769. return EnumMousePointPosition.MouseSizeTopLeft;
  770. }
  771. //MouseSizeTopRight 下右
  772. if ((e.X > point.X) && (e.Y < point.Y))
  773. {
  774. return EnumMousePointPosition.MouseSizeTopRight;
  775. }
  776. //MouseSizeLeft 左侧
  777. if ((e.X < point.X) && (e.Y == point.Y))
  778. {
  779. return EnumMousePointPosition.MouseSizeLeft;
  780. }
  781. //MouseSizeRight 右侧
  782. if ((e.X > point.X) && (e.Y == point.Y))
  783. {
  784. return EnumMousePointPosition.MouseSizeRight;
  785. }
  786. //MouseSizeTop 上侧
  787. if ((e.X == point.X) && (e.Y < point.Y))
  788. {
  789. return EnumMousePointPosition.MouseSizeTop;
  790. }
  791. //MouseSizeBottom 下侧
  792. if ((e.X == point.X) && (e.Y > point.Y))
  793. {
  794. return EnumMousePointPosition.MouseSizeBottom;
  795. }
  796. //MouseSizeBottomRight 下左
  797. if ((e.X < point.X) && (e.Y > point.Y))
  798. {
  799. return EnumMousePointPosition.MouseSizeBottomLeft;
  800. }
  801. //MouseSizeBottomRight 下右
  802. if ((e.X > point.X) && (e.Y > point.Y))
  803. {
  804. return EnumMousePointPosition.MouseSizeBottomRight;
  805. }
  806. return EnumMousePointPosition.MouseSizeNone;
  807. }
  808. protected override void OnMouseDown(MouseEventArgs e)
  809. {
  810. lblFocus.Focus();
  811. Point _Point ;
  812. //判断当前是否手绘
  813. if (m_IsDrawMeasure)
  814. {
  815. this.m_MouseDownPoint = new Point(e.X, e.Y);
  816. COTSSample workSample = m_MeasureAppForm.m_ProjParam.GetWorkSample();
  817. if (workSample == null) return;
  818. string sampleHoleName = workSample.GetSampleHoleName();
  819. string sampleName = workSample.GetName();
  820. //绘制多边形 测量区域
  821. if (m_DrawMeasureType == CreateRectangleType.Polygon)
  822. {
  823. if (m_DrawMeasureGDIObject == null)
  824. {
  825. m_DrawMeasureGDIObject = new CRectangleGDIObject(new List<PointF>(), CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
  826. }
  827. var polygonPoints = m_DrawMeasureGDIObject.GetPolygonPointFList();
  828. if (m_IsDrawPolygonFinish)
  829. {
  830. DialogResult dResult = MessageBox.Show(table["message10"].ToString(), table["message11"].ToString(), MessageBoxButtons.YesNo);
  831. if (dResult == DialogResult.Yes)
  832. {
  833. Point startPoint = new Point((int)(polygonPoints[0].X), (int)(polygonPoints[0].Y));//the last point is the first point too.we get the first point as the last point.
  834. polygonPoints.Add(startPoint);
  835. CRectangleGDIObject polygonGdi =new CRectangleGDIObject (polygonPoints, CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
  836. polygonGdi.SetZoomNumber(m_visualStage.GetZoomNum());
  837. polygonGdi.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
  838. polygonGdi.SetPolygonPointFList(polygonPoints);
  839. polygonGdi.IsWorkSample = true;
  840. var sam = GetVisualSampleByName(sampleName);
  841. if (sam == null) return;
  842. sam.SetMeasureGDIObject(polygonGdi);
  843. m_DrawPolygonFinishGDIObject = null;
  844. m_DrawMeasureGDIObject = null;
  845. var para = m_visualStage.GetSampleMeasurePara(sam.GetMeasureGDIObject());
  846. m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);
  847. m_MeasureAppForm.SwitchWSample(m_SampleSelectName);
  848. //-------------------- draw measrue field and save these data to sample
  849. PrepareMeasureField(sam, MSR_RUN_TYPE.RUNMEASURE);
  850. //--------------------
  851. Invalidate();
  852. m_IsDrawMeasure = false;
  853. m_IsDrawPolygonFinish = false;
  854. this.Cursor = Cursors.Default;
  855. return;
  856. }
  857. else
  858. {
  859. return;
  860. }
  861. }
  862. polygonPoints.Add(m_MouseDownPoint);
  863. m_DrawMeasureGDIObject.SetPolygonPointFList(polygonPoints);
  864. return;
  865. }
  866. else if(m_DrawMeasureType == CreateRectangleType.CircleByThreePoints)
  867. {
  868. if (m_DrawMeasureGDIObject == null)
  869. {
  870. m_DrawMeasureGDIObject = new CRectangleGDIObject(new List<PointF>(), CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
  871. }
  872. var m_PolygonPoint = m_DrawMeasureGDIObject.GetPolygonPointFList();
  873. m_PolygonPoint.Add(m_MouseDownPoint);
  874. if (m_PolygonPoint.Count == 3)//three point can make a circle .
  875. {
  876. m_DrawMeasureType = (int)CreateRectangleType.Circle;
  877. float r = 0;
  878. PointF Centerpoint ;
  879. GetTriangleExcenterRadius(m_PolygonPoint[0], m_PolygonPoint[1], m_PolygonPoint[2], out r, out Centerpoint);
  880. RectangleF rectangleThree = new RectangleF(new PointF(Centerpoint.X - r, Centerpoint.Y - r), new SizeF(r * 2, r * 2));
  881. if (m_visualStage.CheckMeasureAreaIsBeyondStageArea(rectangleThree))
  882. {
  883. m_IsDrawMeasure = true;
  884. }
  885. else
  886. {
  887. m_IsDrawMeasure = false;
  888. return;
  889. }
  890. Color MeasureColor = Color.Red;
  891. CRectangleGDIObject CRectangleGDI =new CRectangleGDIObject (rectangleThree, CreateRectangleType.CircleByThreePoints, (ShapeType)m_DrawMeasureType, sampleName, sampleName, MeasureColor);
  892. m_DrawMeasureGDIObject=CRectangleGDI;
  893. m_DrawMeasureGDIObject.SetZoomNumber(m_visualStage.GetZoomNum());
  894. m_DrawMeasureGDIObject.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
  895. var sam1 = GetVisualSampleByName(sampleName);
  896. if (sam1 == null) return;
  897. sam1.SetMeasureGDIObject(m_DrawMeasureGDIObject);
  898. sam1.GetMeasureGDIObject().SetZoomedRegionF(rectangleThree);
  899. m_DrawMeasureGDIObject = null;
  900. var para = m_visualStage.GetSampleMeasurePara(sam1.GetMeasureGDIObject());
  901. m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);
  902. m_MeasureAppForm.SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  903. m_MeasureAppForm.SwitchWSample(m_SampleSelectName);
  904. Invalidate();
  905. //设置手绘标识
  906. m_IsDrawMeasure = false;
  907. this.Cursor = Cursors.Default;
  908. return;
  909. }
  910. return;
  911. }
  912. else
  913. {
  914. var measureArea = new Rectangle(this.m_MouseDownPoint, new Size(2, 2));
  915. if (m_visualStage.CheckMeasureAreaIsBeyondStageArea(measureArea))
  916. {
  917. m_IsDrawMeasure = true;
  918. }
  919. else
  920. {
  921. m_IsDrawMeasure = false;
  922. return;
  923. }
  924. int sizeWH = 5;
  925. Size size = new Size(sizeWH, sizeWH);
  926. Rectangle rectangle = new Rectangle(m_MouseDownPoint, size);
  927. Color MeasureColor = Color.Red;
  928. CRectangleGDIObject newGDI;
  929. newGDI = new CRectangleGDIObject(rectangle, CreateRectangleType.MeasureArea, (ShapeType)m_DrawMeasureType, sampleName, sampleName, MeasureColor);
  930. newGDI.SetZoomNumber(m_visualStage.GetZoomNum());
  931. newGDI.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
  932. m_DrawMeasureGDIObject = newGDI;
  933. return;
  934. }
  935. }
  936. else if(!m_IsDrawMeasure)
  937. {
  938. if (e.Button == MouseButtons.Right)
  939. {
  940. if (m_MeasureAppForm.MeasureThreadRunFlag)
  941. {
  942. SetShowCMStrip(ContextMenuType.ThreadRunMenu, CMStrip, false);
  943. _Point = this.PointToClient(Cursor.Position);
  944. this.CMStrip.Show(this, _Point);
  945. return;
  946. }
  947. //获取鼠标右键点击位置
  948. m_MouseDownPoint = e.Location;
  949. var sam2 = GetWorkingVisualSample();
  950. if (sam2 != null)
  951. {
  952. foreach (CRectangleGDIObject item in sam2.GetMeasureFieldGDIObjects())
  953. {
  954. if (item.IfZoomContains(e.Location))
  955. {
  956. //样品孔菜单
  957. _Point = this.PointToClient(Cursor.Position);
  958. bool IsTrue = false;
  959. //设置编辑右键菜单项
  960. foreach (CRectangleGDIObject imageItem in m_ImageGDIObjects)
  961. {
  962. if (imageItem.SampleName == item.SampleName)
  963. {
  964. IsTrue = true;
  965. break;
  966. }
  967. }
  968. //设置编辑右键菜单项
  969. SetShowCMStrip(ContextMenuType.FieldMenu, CMStrip, IsTrue);
  970. this.CMStrip.Show(this, _Point);
  971. return;
  972. }
  973. }
  974. }
  975. foreach(var item in m_visualSamples)
  976. {
  977. bool isSelMeasure = false;
  978. if (item.GetMeasureGDIObject().CreateType == CreateRectangleType.Polygon)
  979. {
  980. if(item.GetMeasureGDIObject().GetGPath().IsVisible(e.Location))
  981. {
  982. isSelMeasure = true;
  983. }
  984. }
  985. else
  986. {
  987. if (item.GetMeasureGDIObject().IfZoomContains(e.Location) /*&& !item.MeasureGDIObject.SelColor.Name.Equals("Transparent")*/)
  988. {
  989. isSelMeasure = true;
  990. int WH = 2;
  991. Rectangle rect = new Rectangle(e.Location, new Size(WH, WH));
  992. if (!m_visualStage.CheckMeasureAreaIsBeyondStageArea(rect))
  993. {
  994. break;
  995. }
  996. }
  997. }
  998. if (isSelMeasure)
  999. {
  1000. //删除BSE照片
  1001. bool IsTrue = false;
  1002. //设置编辑右键菜单项
  1003. foreach (CRectangleGDIObject imageItem in m_ImageGDIObjects)
  1004. {
  1005. if (imageItem.SampleName == item.GetSampleName())
  1006. {
  1007. IsTrue = true;
  1008. break;
  1009. }
  1010. }
  1011. //设置编辑右键菜单项
  1012. SetShowCMStrip(ContextMenuType.MeasureMenu, CMStrip, IsTrue);
  1013. _Point = this.PointToClient(Cursor.Position);
  1014. this.CMStrip.Show(this, _Point);
  1015. m_SampleHoleSelectName = item.GetMeasureGDIObject().NameOrHoleName;
  1016. if (m_SampleSelectName != item.GetMeasureGDIObject().SampleName)
  1017. {
  1018. m_SampleSelectName = item.GetSampleName();
  1019. //item.IsSelect = true;
  1020. item.SetIsWorkSample(true);
  1021. //设置工作样品
  1022. m_MeasureAppForm.SwitchWSample(m_SampleSelectName);
  1023. Invalidate();
  1024. }
  1025. return;
  1026. }
  1027. }
  1028. foreach (CRectangleGDIObject item in m_ImageGDIObjects)
  1029. {
  1030. if (item.IfZoomContains(e.Location))
  1031. {
  1032. //样品孔菜单
  1033. _Point = this.PointToClient(Cursor.Position);
  1034. //设置编辑右键菜单项
  1035. SetShowCMStrip(ContextMenuType.SampleHoleBSEImage, CMStrip, false);
  1036. this.CMStrip.Show(this, _Point);
  1037. return;
  1038. }
  1039. }
  1040. //只点击样品上(测量区域被移动到其他地方)
  1041. for (int i = m_visualSamples.Count - 1; i >= 0; i--)
  1042. {
  1043. if (m_visualSamples[i].GetSampleGDIObject().IfZoomContains(e.Location))
  1044. {
  1045. //样品菜单
  1046. var _IsSelectType =ContextMenuType.SampleMenu;
  1047. //将删除样品与测量 设置为不可编辑状态
  1048. _Point = this.PointToClient(Cursor.Position);
  1049. bool flag = false;
  1050. if (m_visualSamples[i].GetMeasureGDIObject().IfZoomContains(e.Location))
  1051. {
  1052. //测量区域菜单
  1053. _IsSelectType = ContextMenuType.MeasureMenu;
  1054. break;
  1055. }
  1056. //设置编辑右键菜单项
  1057. SetShowCMStrip(_IsSelectType, CMStrip, flag);
  1058. this.CMStrip.Show(this, _Point);
  1059. if (m_SampleSelectName != m_visualSamples[i].GetSampleName())
  1060. {
  1061. m_SampleSelectName = m_visualSamples[i].GetSampleName();
  1062. m_SampleHoleSelectName = m_visualSamples[i].GetMeasureGDIObject().NameOrHoleName;
  1063. m_visualSamples[i].SetIsWorkSample(true);
  1064. m_MeasureAppForm.SwitchWSample(m_SampleSelectName);
  1065. Invalidate();
  1066. }
  1067. return;
  1068. }
  1069. }
  1070. //点击样品孔
  1071. CRectangleGDIObject gdiitem;
  1072. if (m_visualStage.IfMouseInSampleHole(e.Location,out gdiitem))
  1073. {
  1074. _Point = this.PointToClient(Cursor.Position);
  1075. //设置编辑右键菜单项
  1076. SetShowCMStrip(ContextMenuType.SampleHoleMenu, CMStrip, false);
  1077. //将删除样品与测量 设置为不可编辑状态
  1078. this.CMStrip.Show(this, _Point);
  1079. m_SampleHoleSelectName = gdiitem.NameOrHoleName;
  1080. return;
  1081. }
  1082. if (m_visualStage.IfMouseInStage(e.Location))
  1083. {
  1084. //设置编辑右键菜单项
  1085. SetShowCMStrip(ContextMenuType.SampleStateMenu, CMStrip, false);
  1086. _Point = this.PointToClient(Cursor.Position);
  1087. this.CMStrip.Show(this, _Point);
  1088. return;
  1089. }
  1090. return;
  1091. }
  1092. else if(e.Button == MouseButtons.Left)
  1093. {
  1094. //如果正在进行测量线程,则退出鼠标点击操作
  1095. if (m_MeasureAppForm.MeasureThreadRunFlag)
  1096. {
  1097. return;
  1098. }
  1099. CRectangleGDIObject stageobj;
  1100. if (m_visualStage.IfMouseInStage(e.Location, out stageobj))
  1101. {
  1102. MouseDownFunction(m_visualStage.GetAllGDIObject(), e);
  1103. //样品
  1104. MouseDownFunction(GetAllVisualSampleGDIObject(), e);
  1105. //样品台中BSE图片
  1106. MouseDownFunction(m_ImageGDIObjects, e);
  1107. }
  1108. //测量区域
  1109. if (Control.ModifierKeys == Keys.Control)// ctrl key is pressed,means changing position or altering the visual sample area.
  1110. {
  1111. var sam = GetWorkingVisualSample();
  1112. if (sam != null)
  1113. {
  1114. var item = sam.GetMeasureGDIObject();
  1115. var selWSampleMeasureStatus = m_MeasureAppForm.m_ProjParam.GetWorkSampleMeasureStatus();
  1116. if (selWSampleMeasureStatus)
  1117. {
  1118. return;
  1119. }
  1120. if (item.CreateType == CreateRectangleType.Polygon)
  1121. {
  1122. bool isSelPolygonPoint = false;
  1123. foreach (PointF itemPoint in item.GetPolygonPointFList())
  1124. {
  1125. if (Math.Abs(itemPoint.X - e.X) <= m_OffsetPX && Math.Abs(itemPoint.Y - e.Y) <= m_OffsetPX)
  1126. {
  1127. isSelPolygonPoint = true;
  1128. item.SelColor = Color.Red;
  1129. item.DraggingPoint = new PointF(itemPoint.X,itemPoint .Y);//e.Location;
  1130. item.IsAltering = true;//this state means operator want to alter the size of the polygon shape.
  1131. item.IsDragging = false;
  1132. break;
  1133. }
  1134. }
  1135. if (!isSelPolygonPoint)//not selecting the polygon point,just dragging on the inside area of the polygon shape.
  1136. {
  1137. if (item.GetGPath().IsVisible(e.Location))
  1138. {
  1139. item.SelColor = Color.Red;
  1140. item.IsDragging = true;
  1141. item.DraggingPoint = e.Location;
  1142. item.IsAltering = false;
  1143. }
  1144. }
  1145. }
  1146. else
  1147. {
  1148. if (item.GetGPath().IsOutlineVisible((float)e.X, (float)e.Y, new Pen(Color.Gray, m_PenWidth)))
  1149. {
  1150. item.SelColor = Color.Red;
  1151. item.IsDragging = false;
  1152. item.DraggingPoint = e.Location;
  1153. item.IsAltering = true;
  1154. }
  1155. else//not outlinevisible then is altering sample area position.
  1156. {
  1157. if (item.IfZoomContains(e.Location))
  1158. {
  1159. item.SelColor = Color.Red;
  1160. item.IsDragging = true;
  1161. item.DraggingPoint = e.Location;
  1162. item.IsAltering = false;
  1163. }
  1164. }
  1165. }
  1166. }
  1167. }
  1168. //click on the sample area without ctrl key,just switch to that sample.
  1169. if (!(Control.ModifierKeys == Keys.Control))
  1170. {
  1171. for (int i = m_visualSamples.Count - 1; i >= 0; i--)
  1172. {
  1173. var sam1 = m_visualSamples[i];
  1174. if (sam1.GetSampleGDIObject().IfZoomContains(e.Location)|| sam1.GetMeasureGDIObject().IfZoomContains(e.Location))
  1175. {
  1176. NLog.LogManager.GetCurrentClassLogger().Info(sam1.GetMeasureGDIObject().GetOrigionalDrawRegionF().ToString());
  1177. var measureItem = sam1.GetMeasureGDIObject();
  1178. measureItem.SelColor = Color.Red;
  1179. //设置为工作样品
  1180. sam1.SetIsWorkSample(true);
  1181. //获取颜色
  1182. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
  1183. sam1.GetSampleGDIObject().SelColor = ColorTranslator.FromHtml(ColorStr);
  1184. m_SampleSelectName = sam1.GetSampleName();
  1185. m_MeasureAppForm.SwitchWSample(m_SampleSelectName);
  1186. break;
  1187. }
  1188. }
  1189. }
  1190. }
  1191. }
  1192. //重绘控件
  1193. Invalidate();
  1194. }
  1195. protected override void OnMouseMove(MouseEventArgs e)
  1196. {
  1197. if (m_MeasureAppForm.MeasureThreadRunFlag)
  1198. {
  1199. return;
  1200. }
  1201. if (m_IsDrawMeasure)
  1202. {
  1203. this.m_MouseMovePoint = new Point(e.X, e.Y);
  1204. if (m_DrawMeasureGDIObject == null) return;//the object must be initialized by mousedown event.
  1205. //绘制多边形
  1206. if (m_DrawMeasureType == CreateRectangleType.Polygon)
  1207. {
  1208. m_DrawMeasureGDIObject.PolygonDrawingEndPoint = this.m_MouseMovePoint;
  1209. var m_PolygonPoint = m_DrawMeasureGDIObject.GetPolygonPointFList();
  1210. //显示直线开始点与鼠标当前位置的直线
  1211. PointF startPoint = new PointF();
  1212. if (m_PolygonPoint.Count > 0)
  1213. {
  1214. startPoint = m_PolygonPoint[0];
  1215. }
  1216. //显示绘制多边形完成标识
  1217. if (m_PolygonPoint.Count > m_PolygonMinPointCount)
  1218. {
  1219. if (Math.Abs(m_MouseMovePoint.X - startPoint.X) <= m_OffsetPX && Math.Abs(m_MouseMovePoint.Y - startPoint.Y) <= m_OffsetPX)
  1220. {
  1221. //显示绘制多边形完成标识
  1222. m_IsDrawPolygonFinish = true;
  1223. int rectSize = m_MinMeasureWidthValue;
  1224. if (m_DrawPolygonFinishGDIObject == null)
  1225. {
  1226. Point PolygonFinishPoint = new Point((int)(startPoint.X - m_MinMeasureWidthValue / 2), (int)(startPoint.Y - m_MinMeasureWidthValue / 2));
  1227. Rectangle pRect = new Rectangle(PolygonFinishPoint, new Size(rectSize, rectSize));
  1228. CRectangleGDIObject createPolygonFinish = new CRectangleGDIObject(pRect, CreateRectangleType.DrawPolygonFinish, "", "", Color.Green);
  1229. m_DrawPolygonFinishGDIObject = createPolygonFinish;
  1230. }
  1231. }
  1232. else
  1233. {
  1234. m_DrawPolygonFinishGDIObject = null;
  1235. m_IsDrawPolygonFinish = false;
  1236. }
  1237. }
  1238. }
  1239. //圆形三点法
  1240. else if (m_DrawMeasureType == CreateRectangleType.CircleByThreePoints)
  1241. {
  1242. m_DrawMeasureGDIObject.PolygonDrawingEndPoint = this.m_MouseMovePoint;
  1243. }
  1244. else
  1245. {
  1246. if (m_DrawMeasureGDIObject == null )
  1247. {
  1248. return;
  1249. }
  1250. RectangleF rectangle = m_DrawMeasureGDIObject.GetZoomedRegion;
  1251. int tmp = (int)Math.Sqrt((m_MouseDownPoint.X - m_MouseMovePoint.X) * (m_MouseDownPoint.X - m_MouseMovePoint.X) + (m_MouseDownPoint.Y - m_MouseMovePoint.Y) * (m_MouseDownPoint.Y - m_MouseMovePoint.Y));
  1252. if (tmp == 0)
  1253. {
  1254. tmp = m_DValue;
  1255. }
  1256. EnumMousePointPosition enumMouse = MousePointPosition(m_MouseDownPoint, m_MouseMovePoint);
  1257. Point LTPoint = new Point();
  1258. Size RBSize = new Size();
  1259. switch (enumMouse)
  1260. {
  1261. case EnumMousePointPosition.MouseSizeTopLeft:
  1262. if (m_DrawMeasureType == (int)CreateRectangleType.Circle)
  1263. {
  1264. LTPoint.X = m_MouseDownPoint.X - tmp;
  1265. LTPoint.Y = m_MouseDownPoint.Y - tmp;
  1266. RBSize.Width = tmp;
  1267. RBSize.Height = tmp;
  1268. rectangle = new Rectangle(LTPoint, RBSize);
  1269. }
  1270. else
  1271. {
  1272. LTPoint.X = m_MouseMovePoint.X;
  1273. LTPoint.Y = m_MouseMovePoint.Y;
  1274. RBSize.Width = m_MouseDownPoint.X - m_MouseMovePoint.X;
  1275. RBSize.Height = m_MouseDownPoint.Y - m_MouseMovePoint.Y;
  1276. rectangle = new Rectangle(LTPoint, RBSize);
  1277. }
  1278. break;
  1279. case EnumMousePointPosition.MouseSizeTopRight:
  1280. if (m_DrawMeasureType == (int)CreateRectangleType.Circle)
  1281. {
  1282. LTPoint.X = m_MouseDownPoint.X;
  1283. LTPoint.Y = m_MouseDownPoint.Y - tmp;
  1284. RBSize.Width = tmp;
  1285. RBSize.Height = tmp;
  1286. rectangle = new Rectangle(LTPoint, RBSize);
  1287. }
  1288. else
  1289. {
  1290. LTPoint.X = m_MouseDownPoint.X;
  1291. LTPoint.Y = m_MouseDownPoint.Y - (m_MouseDownPoint.Y - m_MouseMovePoint.Y);
  1292. RBSize.Width = m_MouseMovePoint.X - m_MouseDownPoint.X;
  1293. RBSize.Height = m_MouseDownPoint.Y - m_MouseMovePoint.Y;
  1294. rectangle = new Rectangle(LTPoint, RBSize);
  1295. }
  1296. break;
  1297. case EnumMousePointPosition.MouseSizeBottomLeft:
  1298. if (m_DrawMeasureType == (int)CreateRectangleType.Circle)
  1299. {
  1300. LTPoint.X = m_MouseDownPoint.X - tmp;
  1301. LTPoint.Y = m_MouseDownPoint.Y;
  1302. RBSize.Width = tmp;
  1303. RBSize.Height = tmp;
  1304. rectangle = new Rectangle(LTPoint, RBSize);
  1305. }
  1306. else
  1307. {
  1308. LTPoint.X = m_MouseDownPoint.X - (m_MouseDownPoint.X - m_MouseMovePoint.X);
  1309. LTPoint.Y = m_MouseDownPoint.Y;
  1310. RBSize.Width = m_MouseDownPoint.X - m_MouseMovePoint.X;
  1311. RBSize.Height = m_MouseMovePoint.Y - m_MouseDownPoint.Y;
  1312. rectangle = new Rectangle(LTPoint, RBSize);
  1313. }
  1314. break;
  1315. case EnumMousePointPosition.MouseSizeBottomRight:
  1316. if (m_DrawMeasureType == (int)CreateRectangleType.Circle)
  1317. {
  1318. LTPoint.X = m_MouseDownPoint.X;
  1319. LTPoint.Y = m_MouseDownPoint.Y;
  1320. RBSize.Width = tmp;
  1321. RBSize.Height = tmp;
  1322. rectangle = new Rectangle(LTPoint, RBSize);
  1323. }
  1324. else
  1325. {
  1326. LTPoint.X = m_MouseDownPoint.X;
  1327. LTPoint.Y = m_MouseDownPoint.Y;
  1328. RBSize.Width = m_MouseMovePoint.X - m_MouseDownPoint.X;
  1329. RBSize.Height = m_MouseMovePoint.Y - m_MouseDownPoint.Y;
  1330. rectangle = new Rectangle(LTPoint, RBSize);
  1331. }
  1332. break;
  1333. }
  1334. //在样品台内部缩放
  1335. if (m_visualStage.CheckMeasureAreaIsBeyondStageArea(rectangle))
  1336. {
  1337. var rec= new Rectangle(LTPoint, RBSize);
  1338. m_DrawMeasureGDIObject.SetZoomedRegionF(new RectangleF(new PointF((rec.X), (rec.Y) ), new SizeF(rec.Width, rec.Height)));
  1339. }
  1340. }
  1341. }
  1342. if( (Control.ModifierKeys == Keys.Control))//is dragging on the edge or on the vertex so we can alter the size of the item.
  1343. {
  1344. var sam = GetWorkingVisualSample();
  1345. if (sam == null) return;
  1346. var curMeasureGdi = sam.GetMeasureGDIObject();
  1347. if (curMeasureGdi.IsAltering)//click on the edge or on the polygon point(or vertex point of rectangle).
  1348. {
  1349. if (curMeasureGdi.CreateType == CreateRectangleType.Polygon)
  1350. {
  1351. for (int i = 0; i < curMeasureGdi.GetPolygonPointFList().Count; i++)
  1352. {
  1353. if (curMeasureGdi.GetPolygonPointFList()[i].X == curMeasureGdi.DraggingPoint.X && curMeasureGdi.GetPolygonPointFList()[i].Y == curMeasureGdi.DraggingPoint.Y)
  1354. {
  1355. //移动点的位置
  1356. RectangleF selPolygonPointRect = new RectangleF(0, 0, 2, 2);
  1357. selPolygonPointRect.X = curMeasureGdi.DraggingPoint.X + e.X - curMeasureGdi.DraggingPoint.X;
  1358. selPolygonPointRect.Y = curMeasureGdi.DraggingPoint.Y + e.Y - curMeasureGdi.DraggingPoint.Y;
  1359. //判断样品是否超越样品台
  1360. if (m_visualStage.CheckMeasureAreaIsBeyondStageArea(selPolygonPointRect))
  1361. {
  1362. List<PointF> polygonPs = curMeasureGdi.GetPolygonPointFList();
  1363. if (i == 0 || i == curMeasureGdi.GetPolygonPointFList().Count - 1)
  1364. {
  1365. curMeasureGdi.DraggingPoint = new Point(e.X, e.Y);
  1366. polygonPs [0] = curMeasureGdi.DraggingPoint;
  1367. polygonPs[curMeasureGdi.GetPolygonPointFList().Count - 1] = curMeasureGdi.DraggingPoint;//the last point and the first point of one polygon object are the same.
  1368. }
  1369. else
  1370. {
  1371. curMeasureGdi.DraggingPoint = new Point(e.X, e.Y);
  1372. polygonPs[i] = curMeasureGdi.DraggingPoint;
  1373. }
  1374. curMeasureGdi.SetPolygonPointFList(polygonPs);
  1375. curMeasureGdi.DraggingPoint = e.Location;
  1376. break;
  1377. }
  1378. }
  1379. }
  1380. }
  1381. else
  1382. {
  1383. if (curMeasureGdi.Shape == ShapeType.RECTANGLE)
  1384. {
  1385. List<PointF> vertexPoint = curMeasureGdi.GetVertexPoints();
  1386. var oldRegion = curMeasureGdi.GetZoomedRegionF();
  1387. for (int i=0;i< vertexPoint.Count;i++)
  1388. {
  1389. var itemPoint = vertexPoint[i];
  1390. PointF lefttop,leftBottom,rightTop,rightBottom;
  1391. float width;
  1392. float height;
  1393. if (Math.Abs(itemPoint.X - e.X) <= m_OffsetPX && Math.Abs(itemPoint.Y - e.Y) <= m_OffsetPX)
  1394. {
  1395. switch (i)
  1396. {
  1397. case 0://left top point
  1398. lefttop = new PointF(e.X, e.Y);
  1399. width = vertexPoint[2].X - e.X;
  1400. height = vertexPoint[1].Y - e.Y;
  1401. curMeasureGdi.SetZoomedRegionF(new RectangleF(lefttop, new SizeF(width, height)));
  1402. break;
  1403. case 1://left bottom
  1404. leftBottom = new PointF(e.X, e.Y);
  1405. width = vertexPoint[3].X - e.X;
  1406. height = -(vertexPoint[0].Y - e.Y);
  1407. curMeasureGdi.SetZoomedRegionF(new RectangleF(new PointF(leftBottom.X,leftBottom.Y-height), new SizeF(width, height)));
  1408. break;
  1409. case 2://right top
  1410. rightTop = new PointF(e.X, e.Y);
  1411. width = -(vertexPoint[0].X - e.X);
  1412. height = (vertexPoint[3].Y - e.Y);
  1413. curMeasureGdi.SetZoomedRegionF(new RectangleF(new PointF(rightTop.X-width, rightTop.Y ), new SizeF(width, height)));
  1414. break;
  1415. case 3://right bottom
  1416. rightBottom = new PointF(e.X, e.Y);
  1417. width = (e.X-vertexPoint[0].X );
  1418. height = ( e.Y-vertexPoint[0].Y);
  1419. curMeasureGdi.SetZoomedRegionF(new RectangleF(new PointF(rightBottom.X-width, rightBottom.Y - height), new SizeF(width, height)));
  1420. break;
  1421. }
  1422. Invalidate();
  1423. }
  1424. }
  1425. }
  1426. else
  1427. {
  1428. PointF gdicenter = m_visualStage.GetCenterPoint(curMeasureGdi.GetZoomedRegion);
  1429. //获取鼠标坐标
  1430. PointF mousePoint = e.Location;
  1431. RectangleF rectTemp;
  1432. //计算偏离半径
  1433. float a = (gdicenter.X - mousePoint.X) * (gdicenter.X - mousePoint.X);
  1434. float b = (gdicenter.Y - mousePoint.Y) * (gdicenter.Y - mousePoint.Y);
  1435. float c = a + b;
  1436. double r = System.Math.Sqrt(c);
  1437. float width = (float)r * 2;
  1438. rectTemp = new RectangleF(gdicenter.X - (float)r, gdicenter.Y - (float)r, width, width);
  1439. if (m_visualStage.CheckMeasureAreaIsBeyondStageArea(rectTemp))
  1440. {
  1441. //如果大于最小测量高度 设置图形大小
  1442. if (rectTemp.Width / curMeasureGdi.GetZoomNumber() > m_MinMeasureWidthValue)
  1443. {
  1444. curMeasureGdi.SetZoomedRegionF(rectTemp);
  1445. curMeasureGdi.DraggingPoint = e.Location;
  1446. }
  1447. }
  1448. else
  1449. {
  1450. return;
  1451. }
  1452. Invalidate();
  1453. return;
  1454. }
  1455. }
  1456. }
  1457. else if(curMeasureGdi.IsDragging)
  1458. {
  1459. if (curMeasureGdi.GetGPath().IsVisible(e.Location))
  1460. {
  1461. if (m_visualStage.GetEdgeGDIObj().GetGPath().IsVisible(e.Location))
  1462. {
  1463. curMeasureGdi.PositionAltering(e.Location, true);
  1464. }
  1465. }
  1466. }
  1467. }
  1468. else
  1469. {
  1470. //样品台
  1471. MouseMoveFucntion(m_visualStage.GetAllGDIObject(), e);
  1472. //样品
  1473. MouseMoveFucntion(GetAllVisualSampleGDIObject(), e);
  1474. //样品孔BSE图片
  1475. MouseMoveFucntion(m_ImageGDIObjects, e);
  1476. }
  1477. //显示XY轴
  1478. m_visualStage.ShowSemCoordvAL(e.Location, m_MeasureAppForm);
  1479. Invalidate();
  1480. }
  1481. protected override void OnMouseUp(MouseEventArgs e)
  1482. {
  1483. //如果正在进行测量线程,则退出鼠标点击操作
  1484. if (m_MeasureAppForm.MeasureThreadRunFlag)
  1485. {
  1486. return;
  1487. }
  1488. var sam = GetWorkingVisualSample();
  1489. //判断当前是否手绘
  1490. if (m_IsDrawMeasure)
  1491. {
  1492. //绘制多边形
  1493. if (m_DrawMeasureType != CreateRectangleType.Polygon && m_DrawMeasureType != CreateRectangleType.CircleByThreePoints)
  1494. {
  1495. var item = m_DrawMeasureGDIObject;
  1496. item.NameOrHoleName = sam.GetMeasureGDIObject().NameOrHoleName;
  1497. item.IsWorkSample = sam.GetMeasureGDIObject().IsWorkSample;
  1498. sam.GetMeasureFieldGDIObjects().Clear();
  1499. sam.SetMeasureGDIObject(item);
  1500. var para = m_visualStage.GetSampleMeasurePara(item);
  1501. m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);
  1502. m_MeasureAppForm.SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  1503. PrepareMeasureField(sam, MSR_RUN_TYPE.RUNMEASURE);
  1504. m_DrawMeasureGDIObject = null;
  1505. this.Cursor = Cursors.Default;
  1506. //设置手绘标识
  1507. m_IsDrawMeasure = false;
  1508. }
  1509. }
  1510. if (sam != null)
  1511. {
  1512. var measureItem = sam.GetMeasureGDIObject();
  1513. if (measureItem.IsDragging || measureItem.IsAltering)//while pressing ctrl key then it must be altering something(position or size)
  1514. {
  1515. var selWSampleMeasureStatus = m_MeasureAppForm.m_ProjParam.GetWorkSampleMeasureStatus();
  1516. if (!selWSampleMeasureStatus)
  1517. {
  1518. var para = m_visualStage.GetSampleMeasurePara(measureItem);
  1519. m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);//set the altering result to the public parameter object
  1520. this.Cursor = System.Windows.Forms.Cursors.Default;
  1521. PrepareMeasureField(sam, m_MeasureAppForm.GetRunType());
  1522. }
  1523. measureItem.IsAltering = false;
  1524. measureItem.IsDragging = false;
  1525. Invalidate();
  1526. }
  1527. }
  1528. //only moving the whole stage
  1529. MouseUpFucntion(m_visualStage.GetAllGDIObject(), e);
  1530. //样品
  1531. MouseUpFucntion(GetAllVisualSampleGDIObject(), e);
  1532. //样品孔中BSE图片
  1533. MouseUpFucntion(m_ImageGDIObjects, e);
  1534. }
  1535. protected override void OnPaint(PaintEventArgs e)//处理重绘情况
  1536. {
  1537. OnPaint(e, m_visualStage.GetAllGDIObject());
  1538. OnPaint(e, GetOnlyVisualSampleGDIObject());
  1539. if (IsShowSampleHoleImage)
  1540. {
  1541. if (m_ImageGDIObjects.Count > 0)
  1542. {
  1543. OnPaint(e, m_ImageGDIObjects);
  1544. }
  1545. }
  1546. OnPaint(e, GetAllVisualFieldGdiObject());
  1547. if (m_DrawMeasureGDIObject != null)
  1548. {
  1549. m_DrawMeasureGDIObject.OnPaint(e);
  1550. }
  1551. if(m_DrawPolygonFinishGDIObject!=null) m_DrawPolygonFinishGDIObject.OnPaint(e);
  1552. }
  1553. public void OnPaint(PaintEventArgs e, List<CRectangleGDIObject> m_ObjectGDIObjects)//处理重绘情况
  1554. {
  1555. foreach (CRectangleGDIObject item in m_ObjectGDIObjects)
  1556. {
  1557. if (item != null)
  1558. {
  1559. item.OnPaint(e);
  1560. }
  1561. }
  1562. }
  1563. protected override void OnMouseWheel(MouseEventArgs e)
  1564. {
  1565. var currentZoomNum = m_visualStage.GetZoomNum();
  1566. //如果正在进行测量线程,则退出鼠标点击操作
  1567. if (m_MeasureAppForm.MeasureThreadRunFlag)
  1568. {
  1569. return;
  1570. }
  1571. if (e.Delta > 0)
  1572. {
  1573. #region 计算标尺尺寸部份-----放大------
  1574. //计算标尺实际占用像素的宽度
  1575. f_ruler_size = f_old_ruler_size * currentZoomNum;
  1576. control_Ruler2.RulerWidth = Convert.ToInt32(f_ruler_size);
  1577. control_Ruler2.Value = 1;
  1578. //放大过长时,这里将宽度与代表的实际宽度进行折半显示
  1579. while (control_Ruler2.Width > 300)
  1580. {
  1581. control_Ruler2.RulerWidth = Convert.ToInt32(control_Ruler2.RulerWidth) / 2;
  1582. control_Ruler2.Value = control_Ruler2.Value * 2;
  1583. }
  1584. control_Ruler2.SetValue(control_Ruler2.RulerWidth, control_Ruler2.Value.ToString());
  1585. #endregion
  1586. }
  1587. else
  1588. {
  1589. if (currentZoomNum >= f_zoom_mix)
  1590. {
  1591. #region 计算标尺尺寸部份-----缩小
  1592. f_ruler_size = f_old_ruler_size * currentZoomNum;
  1593. control_Ruler2.RulerWidth = Convert.ToInt32(f_ruler_size);
  1594. control_Ruler2.Value = 1;
  1595. while (control_Ruler2.Width > 300)
  1596. {
  1597. control_Ruler2.RulerWidth = Convert.ToInt32(control_Ruler2.RulerWidth) / 2;
  1598. control_Ruler2.Value = control_Ruler2.Value * 2;
  1599. }
  1600. control_Ruler2.SetValue(control_Ruler2.RulerWidth, control_Ruler2.Value.ToString());
  1601. #endregion
  1602. }
  1603. }
  1604. //设置记录每次比例缩放后的总体比例系数
  1605. if (e.Delta > 0)
  1606. {
  1607. currentZoomNum += 0.1f;
  1608. }
  1609. else
  1610. {
  1611. currentZoomNum -= 0.1f;
  1612. if (currentZoomNum < 1)
  1613. {
  1614. currentZoomNum = 1;
  1615. }
  1616. if (currentZoomNum == 1)
  1617. {
  1618. //标尺恢复初始
  1619. f_ruler_size = f_old_ruler_size;
  1620. control_Ruler2.RulerWidth = Convert.ToInt32(f_ruler_size);
  1621. control_Ruler2.ShowString = "1mm";
  1622. control_Ruler2.SetValue(control_Ruler2.RulerWidth);
  1623. }
  1624. }
  1625. MouseWheelFunction(m_ImageGDIObjects, e.Location, currentZoomNum);
  1626. MouseWheelFunction(GetAllVisualSampleGDIObject(), e.Location, currentZoomNum);
  1627. //样品孔
  1628. MouseWheelFunction(m_visualStage.GetAllGDIObject(), e.Location, currentZoomNum);
  1629. base.OnMouseWheel(e);
  1630. //重新绘制
  1631. Invalidate();
  1632. }
  1633. private void MouseWheelFunction(List<CRectangleGDIObject> objList, Point mousePoint, float ZoomNum)
  1634. {
  1635. for (int i = 0; i < objList.Count; i++)
  1636. {
  1637. objList[i].Zoom(mousePoint, ZoomNum);
  1638. }
  1639. }
  1640. #endregion
  1641. #region 鼠标方法操作
  1642. public void MouseDownFunction(List<CRectangleGDIObject> objList, MouseEventArgs e)
  1643. {
  1644. foreach (CRectangleGDIObject item in objList)
  1645. {
  1646. item.IsMoving = true;
  1647. item.DraggingPoint = e.Location;
  1648. }
  1649. }
  1650. public void MouseMoveFucntion(List<CRectangleGDIObject> objList, MouseEventArgs e)
  1651. {
  1652. foreach (CRectangleGDIObject item in objList)
  1653. {
  1654. if (item.IsMoving)
  1655. {
  1656. item.Move(e.Location);
  1657. }
  1658. }
  1659. }
  1660. public void MouseUpFucntion(List<CRectangleGDIObject> objList, MouseEventArgs e)
  1661. {
  1662. foreach (CRectangleGDIObject item in objList)
  1663. {
  1664. if (item.IsDragging)
  1665. {
  1666. item.IsDragging = false;
  1667. item.DraggingPoint = Point.Empty;
  1668. }
  1669. if (item.IsMoving)
  1670. {
  1671. item.IsMoving = false;
  1672. item.DraggingPoint = Point.Empty;
  1673. }
  1674. }
  1675. }
  1676. #endregion
  1677. private void DeleteSampleInfo( string sampleSelectName)
  1678. {
  1679. if (ShowDeleteDialog(sampleSelectName))
  1680. {
  1681. //设置当前状态
  1682. m_MeasureAppForm.SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  1683. m_MeasureAppForm.DeleteSample(sampleSelectName);
  1684. }
  1685. return ;
  1686. }
  1687. private bool ShowDeleteDialog(string sampleName)
  1688. {
  1689. //国际化
  1690. OTSCommon.Language lan = new OTSCommon.Language();
  1691. Hashtable table = lan.GetNameTable("OTSIncAMeasureAppForm");
  1692. string str1 = table["message5"].ToString();
  1693. string str2 = table["message6"].ToString();
  1694. string sDeleteSampleName = str1;
  1695. sDeleteSampleName += sampleName;
  1696. sDeleteSampleName += " 信息 ?";
  1697. if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Delete sample information prompt", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
  1698. {
  1699. return true;
  1700. }
  1701. else
  1702. {
  1703. return false;
  1704. }
  1705. }
  1706. public bool setSlopFocusParam(_5_OTSMeasureStatuImageFun.SlopFocus slopFocus)
  1707. {
  1708. if (slopFocus == null)
  1709. {
  1710. return false;
  1711. }
  1712. else
  1713. {
  1714. m_MeasureAppForm.m_ProjParam.GetWorkSample().GetMsrParams().SlopParam = slopFocus.GetCSlopFocusParam();
  1715. return true;
  1716. }
  1717. }
  1718. protected override bool ProcessDialogKey(Keys keyData)
  1719. {
  1720. if (keyData == Keys.Up || keyData == Keys.Down || keyData == Keys.Left || keyData == Keys.Right)
  1721. {
  1722. return false;
  1723. }
  1724. else
  1725. {
  1726. return base.ProcessDialogKey(keyData);
  1727. }
  1728. }
  1729. private void OTSSamplespaceWindow_KeyDown(object sender, KeyEventArgs e)
  1730. {
  1731. KeyDowns();
  1732. }
  1733. private void OTSSamplespaceWindow_KeyUp(object sender, KeyEventArgs e)
  1734. {
  1735. //键盘抬起时,将选择区域的标识 设置为未选择状态
  1736. this.Cursor = System.Windows.Forms.Cursors.Default;
  1737. this.Invalidate();
  1738. }
  1739. public void KeyDowns()
  1740. {
  1741. //鼠标相对于屏幕的坐标
  1742. Point p1 = MousePosition;
  1743. //鼠标相对于窗体的坐标
  1744. Point mousePoint = this.PointToClient(p1);
  1745. Pen GrayPen = new Pen(Color.Gray, m_PenWidth);
  1746. //设置鼠标在样品测量区域上的样式
  1747. foreach (var sam in m_visualSamples)
  1748. {
  1749. var item = sam.GetMeasureGDIObject();
  1750. if (item.GetGPath() != null)
  1751. {
  1752. if (item.CreateType == CreateRectangleType.Polygon)
  1753. {
  1754. //在多边形点附近切换光标
  1755. foreach (PointF itemPoint in item.GetPolygonPointFList())
  1756. {
  1757. if (Math.Abs(itemPoint.X - mousePoint.X) <= m_OffsetPX && Math.Abs(itemPoint.Y - mousePoint.Y) <= m_OffsetPX)
  1758. {
  1759. if (Control.ModifierKeys == Keys.Control)
  1760. {
  1761. this.Cursor = System.Windows.Forms.Cursors.Hand;
  1762. return;
  1763. }
  1764. }
  1765. }
  1766. if (item.GetGPath().IsVisible(mousePoint))
  1767. {
  1768. if (Control.ModifierKeys == Keys.Control)
  1769. {
  1770. this.Cursor = System.Windows.Forms.Cursors.SizeAll;
  1771. return;
  1772. }
  1773. }
  1774. }
  1775. else
  1776. {
  1777. if (item.GetGPath().IsOutlineVisible(mousePoint, GrayPen))
  1778. {
  1779. if (item.Shape == ShapeType.RECTANGLE)
  1780. {
  1781. List<PointF> vertexPoint = item.GetVertexPoints();
  1782. foreach (PointF itemPoint in vertexPoint)
  1783. {
  1784. if (Math.Abs(itemPoint.X - mousePoint.X) <= m_OffsetPX && Math.Abs(itemPoint.Y - mousePoint.Y) <= m_OffsetPX)
  1785. {
  1786. if (Control.ModifierKeys == Keys.Control)
  1787. {
  1788. this.Cursor = System.Windows.Forms.Cursors.Hand;
  1789. return;
  1790. }
  1791. }
  1792. }
  1793. }
  1794. else
  1795. {
  1796. if (Control.ModifierKeys == Keys.Control)
  1797. {
  1798. this.Cursor = System.Windows.Forms.Cursors.NoMove2D;
  1799. return;
  1800. }
  1801. }
  1802. }
  1803. if (item.IfZoomContains(mousePoint))
  1804. {
  1805. if (Control.ModifierKeys == Keys.Control)
  1806. {
  1807. this.Cursor = System.Windows.Forms.Cursors.SizeAll;
  1808. return;
  1809. }
  1810. }
  1811. }
  1812. }
  1813. }
  1814. //设置鼠标在样品上的样式
  1815. foreach (var sam in m_visualSamples)
  1816. {
  1817. var item = sam.GetSampleGDIObject();
  1818. if (!item.SelColor.Name.Equals("Transparent"))
  1819. {
  1820. if (item.IfZoomContains(mousePoint))
  1821. {
  1822. if ((Control.ModifierKeys == Keys.Alt))
  1823. {
  1824. this.Cursor = System.Windows.Forms.Cursors.SizeAll;
  1825. return;
  1826. }
  1827. }
  1828. }
  1829. }
  1830. }
  1831. public void KeyUps()
  1832. {
  1833. this.Cursor = System.Windows.Forms.Cursors.Default;
  1834. }
  1835. #region 处理方法总汇
  1836. #region 清除所需图形
  1837. public void ClearDrawInfo()
  1838. {
  1839. try
  1840. {
  1841. m_visualStage.cleargdiobj();
  1842. m_visualSamples.Clear();
  1843. if (m_ImageGDIObjects != null)
  1844. {
  1845. m_ImageGDIObjects.Clear();
  1846. }
  1847. if (m_ImageOfFieldGDIObjects != null)
  1848. {
  1849. m_ImageOfFieldGDIObjects.Clear();
  1850. }
  1851. if (m_DrawMeasureGDIObject != null)
  1852. {
  1853. m_DrawMeasureGDIObject = null;
  1854. }
  1855. }
  1856. catch (Exception ex)
  1857. {
  1858. log.Error( ex.ToString() );
  1859. }
  1860. }
  1861. #endregion
  1862. #endregion
  1863. #region 绘制样品以及测量区域
  1864. /// <summary>
  1865. /// 绘制样品以及测量区域
  1866. /// </summary>
  1867. /// <param name="SMeasrueAreaList">测量区域的集合</param>
  1868. public void DrawSampleAndMeasureInfo(SampleMeasurePara SMeasrueArea)
  1869. {
  1870. var item = m_visualStage.GetHoleGDIByHoleName(SMeasrueArea.sampleHoleName);
  1871. if (item!=null)
  1872. {
  1873. CVisualSampleArea sam;
  1874. if (AddVisualSample(SMeasrueArea.sampleHoleName, SMeasrueArea.sSampleName,out sam))
  1875. {
  1876. if (SMeasrueArea.iShape ==(ShapeType) CreateRectangleType.Polygon)
  1877. {
  1878. var ps = new List<PointF>();
  1879. foreach (var p in SMeasrueArea.DrawPolygonPointList)
  1880. {
  1881. var ctrlcoordPoint = m_visualStage.OTSCoordToCtrlCoord(p);
  1882. ps.Add(ctrlcoordPoint);
  1883. }
  1884. CRectangleGDIObject polygongdi =new CRectangleGDIObject (ps, CreateRectangleType.Polygon, (ShapeType)SMeasrueArea.iShape, SMeasrueArea.sampleHoleName, SMeasrueArea.sSampleName, Color.Red);
  1885. sam.SetMeasureGDIObject(polygongdi);
  1886. PrepareMeasureField(sam,m_MeasureAppForm.GetRunType());
  1887. }
  1888. else
  1889. {
  1890. PointF xHole = new PointF(SMeasrueArea.MeasureRect.Left, SMeasrueArea.MeasureRect.Top);
  1891. PointF yHole = new PointF(SMeasrueArea.MeasureRect.Right, SMeasrueArea.MeasureRect.Bottom);
  1892. CRectangleGDIObject gdi = m_visualStage.GetCtrlCoordRect(xHole,yHole, (CreateRectangleType)SMeasrueArea.iShape, "", "");
  1893. gdi.SampleName = SMeasrueArea.sSampleName;
  1894. gdi.NameOrHoleName = SMeasrueArea.sampleHoleName;
  1895. gdi.Shape =SMeasrueArea.iShape;
  1896. CRectangleGDIObject measureGdi;
  1897. if (m_visualStage. GetMeasureGdiObjectFromSampleGdi( gdi,out measureGdi))
  1898. {
  1899. sam.SetMeasureGDIObject(measureGdi);
  1900. PrepareMeasureField(sam, m_MeasureAppForm.GetRunType());
  1901. }
  1902. }
  1903. COTSMsrPrjResultData cProjMgr = m_MeasureAppForm.m_ProjParam.GetResultData();
  1904. List<PointF> CompleteFieldList = cProjMgr.GetSampleByName(SMeasrueArea.sSampleName).GetMsrStatus().GetCompletedFieldsCenter();
  1905. if (CompleteFieldList .Count> 0)
  1906. {
  1907. ChangeCompleteFieldMeasureState(CompleteFieldList, Color.Green, sam );
  1908. }
  1909. }
  1910. }
  1911. }
  1912. #endregion
  1913. #region 获取帧图信息
  1914. public void ReadSEMDataAndSetToCurrentSample()
  1915. {
  1916. List<double> semParameters ;
  1917. #region 获取电镜参数
  1918. ////获取Field操作类对象
  1919. if (m_SEMDATAFieldManage == null)
  1920. {
  1921. m_SEMDATAFieldManage = new SEMDATAFieldManage(m_MeasureAppForm.m_ProjParam);
  1922. }
  1923. //判断是否连接电镜
  1924. if (m_SEMDATAFieldManage.InitAndConnection())
  1925. {
  1926. //获取电镜参数 放大倍数与工作距离 [Magnification]:放大倍数 [WorkingDistance]工作距离
  1927. semParameters = m_SEMDATAFieldManage.GetSEMMagAndWDParameter();
  1928. double mag = semParameters[0];
  1929. double wd = semParameters[1];
  1930. if (mag != 0 && wd != 0)
  1931. {
  1932. //设置样品文件中的电镜参数
  1933. m_MeasureAppForm.m_ProjParam.SetWorkingSampleSEMData(wd, mag);
  1934. //将右键SEM数据菜单设置为可编辑状态
  1935. CMStrip.Items[(int)MenuIndex.SetSemData].Enabled = true;
  1936. }
  1937. }
  1938. #endregion
  1939. }
  1940. #region 获取Filed帧图
  1941. public List<CRectangleGDIObject> GetOTSFieldVisualRects(CVisualSampleArea sam, MSR_RUN_TYPE runType)
  1942. {
  1943. List<Point> listCenterPoint ;
  1944. Size rectSize ;
  1945. var m_ResultData = m_MeasureAppForm.m_ProjParam.GetResultData();
  1946. var sample = m_ResultData.GetSampleByName(sam.GetSampleName());
  1947. List<CRectangleGDIObject> visualfieldRects = new List<CRectangleGDIObject>();
  1948. if (GetFieldData(sample,runType,out listCenterPoint, out rectSize))
  1949. {
  1950. for (int i=0;i< listCenterPoint.Count;i++)
  1951. {
  1952. //convert the center point to leftTop point of rectangle.
  1953. Point otsPoint = listCenterPoint[i];
  1954. int left = otsPoint.X - rectSize.Width / 2;
  1955. int top = otsPoint.Y - rectSize.Height / 2;//the ots coordinate is leftbottom is (0,0),but the control coordinate is leftTop is (0,0),so here use minus.
  1956. var rect=new Rectangle(new Point(left,top), rectSize);
  1957. Point lt = new Point(rect.Left, rect.Top);
  1958. Point rb = new Point(rect.Right, rect.Bottom);
  1959. RectangleF visualRect = m_visualStage.GetCtrlCoordRectF(lt, rb);
  1960. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SingleColor);
  1961. string sampleName = sam.GetSampleName();
  1962. string sampleHoleName = sam.GetSampleGDIObject().NameOrHoleName;
  1963. CRectangleGDIObject createRect = new CRectangleGDIObject(visualRect, otsPoint.X, otsPoint.Y, CreateRectangleType.FieldRectangle, sampleHoleName, sampleName, ColorTranslator.FromHtml(ColorStr));
  1964. visualfieldRects.Add(createRect);
  1965. }
  1966. }
  1967. return visualfieldRects;
  1968. }
  1969. public bool GetFieldData(COTSSample sample, MSR_RUN_TYPE runType ,out List<Point> pFields, out Size iSzie)
  1970. {
  1971. pFields = new List<Point>();
  1972. iSzie = new Size();
  1973. COTSSample WSample = sample;
  1974. if (null == WSample)
  1975. {
  1976. return false;
  1977. }
  1978. CDomain pMsrArea = WSample.GetMsrArea();
  1979. COTSImgScanPrm pImgScanParam = WSample.GetMsrParams().GetImageScanParam();
  1980. CFieldPositionMgr pFieldMgr = new CFieldPositionMgr();
  1981. List<PointF> listPoint = new List<PointF>();
  1982. listPoint.Clear();
  1983. //设置测量区域
  1984. CSEMDataMsr pSEMDataMsr; ;
  1985. if (runType == MSR_RUN_TYPE.RUNSampleHoleImage)
  1986. {
  1987. pSEMDataMsr = new CSEMDataMsr();
  1988. pSEMDataMsr.SetScanFieldSize100(m_visualStage.GetOTSSampleStageData().iScanFieldSize100);
  1989. double dMagnification = m_MeasureAppForm.m_ProjParam.GetDefaultParam().GetStageDataParam().GetMinMag();//using the min mag to photo the hole image.
  1990. pSEMDataMsr.SetMagnification(dMagnification);
  1991. }
  1992. else
  1993. {
  1994. pSEMDataMsr = WSample.GetSEMDataMsr();
  1995. }
  1996. //calculate all the field position point in OTS coordination.
  1997. if (!pFieldMgr.Init(pMsrArea, pImgScanParam, pSEMDataMsr, listPoint))
  1998. {
  1999. return false;
  2000. }
  2001. pFields = pFieldMgr.GetFieldCentrePoints();
  2002. var oValue = new Rectangle();
  2003. if (!pFieldMgr.GetFieldRectByIndex(0, ref oValue))
  2004. {
  2005. return false;
  2006. }
  2007. iSzie = oValue.Size;
  2008. return true;
  2009. }
  2010. #endregion
  2011. public void PrepareMeasureField(CVisualSampleArea sam, MSR_RUN_TYPE runType)
  2012. {
  2013. try
  2014. {
  2015. List<CRectangleGDIObject> visualfieldRects = null;
  2016. visualfieldRects = GetOTSFieldVisualRects(sam,runType);//get all the possible field rects through C++ code.
  2017. if (runType == MSR_RUN_TYPE.RUNSampleHoleImage)
  2018. {
  2019. foreach (var r in visualfieldRects)
  2020. {
  2021. r.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
  2022. r.SetZoomNumber(m_visualStage.GetZoomNum());
  2023. m_ImageOfFieldGDIObjects.Add(r);
  2024. }
  2025. }
  2026. else if (runType == MSR_RUN_TYPE.RUNMEASURE)
  2027. {
  2028. sam.GetMeasureGDIObject().SubItems().Clear();
  2029. //添加帧图列表
  2030. int sequenceNum=0;
  2031. for (int i=0;i<visualfieldRects.Count;i++)
  2032. {
  2033. var r = visualfieldRects[i];
  2034. if (sam.GetMeasureGDIObject().ifRectangleIntersect(r))//filter the unmeasure fields
  2035. {
  2036. r.SequenceNum = sequenceNum++;
  2037. sam.AddFieldGDIObject(r);
  2038. }
  2039. }
  2040. SaveFieldPositionInfoToSample(sam);
  2041. m_MeasureAppForm.UpdatePropertyVal();
  2042. }
  2043. }
  2044. catch (Exception ex)
  2045. {
  2046. log.Error( ex.ToString());
  2047. }
  2048. Invalidate();
  2049. }
  2050. public void SaveFieldPositionInfoToSample(CVisualSampleArea sam)
  2051. {
  2052. var m_ResultData = m_MeasureAppForm.m_ProjParam.GetResultData();
  2053. var sample = m_ResultData.GetSampleByName(sam.GetSampleName());
  2054. var fields = sam.GetMeasureFieldGDIObjects();
  2055. sample.ClearFields();
  2056. for (int i=0;i<fields.Count;i++ )
  2057. {
  2058. var f = fields[i];
  2059. var otsPoint = new Point(f.OTSX, f.OTSY);
  2060. sample.AddFieldData(otsPoint);
  2061. }
  2062. }
  2063. #endregion
  2064. #region 设置SEM数据
  2065. public bool SetSEMDATAMParameter(double magnification, double semWorkingDistance)
  2066. {
  2067. #region 获取电镜参数
  2068. //获取Field操作类对象
  2069. if (m_SEMDATAFieldManage == null)
  2070. {
  2071. m_SEMDATAFieldManage = new SEMDATAFieldManage(m_MeasureAppForm.m_ProjParam);
  2072. }
  2073. //判断是否连接电镜
  2074. if (m_SEMDATAFieldManage.InitAndConnection())
  2075. {
  2076. //获取电镜参数
  2077. bool mFlag ;
  2078. bool wFlag;
  2079. mFlag = m_SEMDATAFieldManage.SetGMagnification(magnification);
  2080. wFlag = m_SEMDATAFieldManage.SetSemWorkingDistance(semWorkingDistance);
  2081. if (mFlag || wFlag)
  2082. {
  2083. return true;
  2084. }
  2085. }
  2086. return false;
  2087. #endregion
  2088. }
  2089. public bool GetSEMDATAMParameter(ref double magnification, ref double WorkingDistance)
  2090. {
  2091. #region 获取电镜参数
  2092. //获取Field操作类对象
  2093. if (m_SEMDATAFieldManage == null)
  2094. {
  2095. m_SEMDATAFieldManage = new SEMDATAFieldManage(m_MeasureAppForm.m_ProjParam);
  2096. }
  2097. //判断是否连接电镜
  2098. if (m_SEMDATAFieldManage.InitAndConnection())
  2099. {
  2100. //获取电镜参数
  2101. List<double> semParameters = m_SEMDATAFieldManage.GetSEMMagAndWDParameter();
  2102. //放大倍数
  2103. magnification = semParameters[0];
  2104. WorkingDistance = semParameters[1];
  2105. return true;
  2106. }
  2107. return false;
  2108. #endregion
  2109. }
  2110. #endregion
  2111. #region 驱动到SEM当前位置
  2112. protected void SetMeasureToSEMLocation()
  2113. {
  2114. bool selWSampleMeasureStatus = m_MeasureAppForm.m_ProjParam.GetWorkSampleMeasureStatus();
  2115. if (selWSampleMeasureStatus)
  2116. {
  2117. return;
  2118. }
  2119. try
  2120. {
  2121. List<double> SemLocation = new List<double>();
  2122. if (GetSemLocation(ref SemLocation))
  2123. {
  2124. PointF OTSLocation = m_MeasureAppForm.m_ProjParam.ConverSEMToOTSCoord(new PointF((int)Math.Round(SemLocation[(int)XYIndex.X], 0), (int)Math.Round(SemLocation[(int)XYIndex.Y], 0)));
  2125. var sam = GetWorkingVisualSample();
  2126. var MeasureItem = sam.GetMeasureGDIObject();
  2127. var measurePos = m_visualStage.OTSCoordToCtrlCoord(OTSLocation);
  2128. MeasureItem.DraggingPoint = MeasureItem.GetCenterPoint();
  2129. MeasureItem.PositionAltering(measurePos,false);
  2130. var para = m_visualStage.GetSampleMeasurePara(MeasureItem);
  2131. m_MeasureAppForm.m_ProjParam.SetWorkSampleHoleAndMeasureArea(para);
  2132. }
  2133. Invalidate();
  2134. }
  2135. catch (Exception ex)
  2136. {
  2137. log.Error( ex.ToString());
  2138. }
  2139. }
  2140. #endregion
  2141. #region 驱动SEM到当前位置
  2142. public bool SetSEMCurrentLocation()
  2143. {
  2144. bool bret=false;
  2145. //获取Field操作类对象
  2146. if (m_SEMDATAFieldManage == null)
  2147. {
  2148. m_SEMDATAFieldManage = new SEMDATAFieldManage(m_MeasureAppForm.m_ProjParam);
  2149. }
  2150. //判断是否连接电镜
  2151. if (m_SEMDATAFieldManage.InitAndConnection())
  2152. {
  2153. bret = m_SEMDATAFieldManage.SetSEMCurrentLocation(m_MouseDownPoint, m_visualStage);
  2154. }
  2155. return bret;
  2156. }
  2157. #endregion
  2158. #region 设置SEM到中心
  2159. public bool SetSEMToCenterPoint()
  2160. {
  2161. try
  2162. {
  2163. //获取Field操作类对象
  2164. if (m_SEMDATAFieldManage == null)
  2165. {
  2166. m_SEMDATAFieldManage = new SEMDATAFieldManage(m_MeasureAppForm.m_ProjParam);
  2167. }
  2168. //判断是否连接电镜
  2169. bool bret = false;
  2170. var sam = GetWorkingVisualSample();
  2171. if (m_SEMDATAFieldManage.InitAndConnection())
  2172. {
  2173. bret = (m_SEMDATAFieldManage.DriveSEMToLocation(m_MouseDownPoint, m_visualStage, sam.GetMeasureFieldGDIObjects()));
  2174. }
  2175. return bret;
  2176. }
  2177. catch (Exception ex)
  2178. {
  2179. log.Error("OTSSamplespaceWindow_" + "SetSEMToCenterPoint" + ":" + ex.ToString() + "");
  2180. return false;
  2181. }
  2182. }
  2183. #endregion
  2184. #region 获取SEM当前位置
  2185. public bool GetSemLocation(ref List<double> SemLocation)
  2186. {
  2187. //获取Field操作类对象
  2188. if (m_SEMDATAFieldManage == null)
  2189. {
  2190. m_SEMDATAFieldManage = new SEMDATAFieldManage(m_MeasureAppForm.m_ProjParam);
  2191. }
  2192. //判断是否连接电镜
  2193. bool bret=false;
  2194. if (m_SEMDATAFieldManage.InitAndConnection())
  2195. {
  2196. bret = m_SEMDATAFieldManage.GetSemLocation(ref SemLocation);
  2197. }
  2198. return bret;
  2199. }
  2200. #endregion
  2201. #region 显示标尺
  2202. /// <summary>
  2203. /// 是否显示标尺控件
  2204. /// </summary>
  2205. /// <param name="b_show"></param>
  2206. public void ShowRulerLocation()
  2207. {
  2208. //设置标尺位置
  2209. Point rulerLocation = new Point(10, this.Height - (int)(control_Ruler2.Height * 2));
  2210. this.control_Ruler2.Location = rulerLocation;
  2211. control_Ruler2.Visible = true;
  2212. var m_GlobalZoomNum = m_visualStage.GetZoomNum();
  2213. f_ruler_size = Convert.ToInt32(f_old_ruler_size * m_GlobalZoomNum);
  2214. control_Ruler2.RulerWidth = Convert.ToInt32(f_ruler_size);
  2215. control_Ruler2.Value = 1;
  2216. //放大过长时,这里将宽度与代表的实际宽度进行折半显示
  2217. while (control_Ruler2.Width > 300)
  2218. {
  2219. control_Ruler2.RulerWidth = Convert.ToInt32(control_Ruler2.RulerWidth) / 2;
  2220. control_Ruler2.Value = control_Ruler2.Value * 2;
  2221. }
  2222. control_Ruler2.SetValue(control_Ruler2.RulerWidth, control_Ruler2.Value.ToString());
  2223. }
  2224. public void RulerInit(StageDrawingData SData)
  2225. {
  2226. control_Ruler2.ShowString = "1mm";
  2227. PointF xDomain = new PointF(SData.StageDomain.Left, SData.StageDomain.Top);
  2228. PointF yDomain = new PointF(SData.StageDomain.Right, SData.StageDomain.Bottom);
  2229. //OTS宽度高度差值
  2230. float widthDomain = Math.Abs(yDomain.X - xDomain.X);
  2231. int length = this.Height > this.Width ? this.Width : this.Height;
  2232. control_Ruler2.RulerWidth = (int)(length / widthDomain * 1000);
  2233. f_ruler_size = f_old_ruler_size = control_Ruler2.RulerWidth;
  2234. control_Ruler2.Value = 1000;
  2235. }
  2236. #endregion
  2237. #region 隐藏与显示样品孔照片
  2238. static bool IsShowSampleHoleImage = true;
  2239. public void ChangeSampleHoleImage()
  2240. {
  2241. IsShowSampleHoleImage = IsShowSampleHoleImage ? false : true;
  2242. Invalidate();
  2243. }
  2244. #endregion
  2245. #region 添加样品孔中BSE图像信息
  2246. public void AddHoleBSEImageData(byte[] ImageData, int width, int height, Point fieldPos)
  2247. {
  2248. CRectangleGDIObject itemWorkSample;
  2249. var sam = GetWorkingVisualSample();
  2250. itemWorkSample = GetWorkingVisualSample().GetSampleGDIObject();
  2251. //获取样品孔BSE图像
  2252. Image bseImage ;
  2253. int m_iWidth = width;
  2254. int m_iHeigh = height;
  2255. RectangleF ImgRegionF;
  2256. float ImgRegionWidth;
  2257. float ImgRegionHeight ;
  2258. if (m_ImageOfFieldGDIObjects.Count > 0)
  2259. {
  2260. for (int i = 0; i < m_ImageOfFieldGDIObjects.Count; i++)
  2261. {
  2262. var ctrlPos = m_visualStage.OTSCoordToCtrlCoord(fieldPos);
  2263. if (m_ImageOfFieldGDIObjects[i].IfContains(ctrlPos))
  2264. {
  2265. ImgRegionF = m_ImageOfFieldGDIObjects[i].GetOrigionalDrawRegionF();
  2266. ImgRegionWidth = Convert.ToInt32(ImgRegionF.Width);
  2267. ImgRegionHeight = Convert.ToInt32(ImgRegionF.Height);
  2268. //获取图片
  2269. bseImage = CImageHandler.ToGrayBitmap(ImageData, m_iWidth, m_iHeigh);
  2270. //绘制图像
  2271. CRectangleGDIObject createImageRect =new CRectangleGDIObject (ImgRegionF, fieldPos.X, fieldPos.Y, itemWorkSample.SampleName, itemWorkSample.NameOrHoleName, bseImage, ImgRegionWidth, ImgRegionHeight, CreateRectangleType.DrawSampleHoleBSEImage);
  2272. //添加至List集合中
  2273. createImageRect.SetInitRegionF(m_ImageOfFieldGDIObjects[i].GetOrigionalDrawRegionF());
  2274. createImageRect.NameOrHoleName = m_ImageOfFieldGDIObjects[i].NameOrHoleName;
  2275. createImageRect.SetZoomNumber(m_visualStage.GetZoomNum());
  2276. createImageRect.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
  2277. m_ImageGDIObjects.Add(createImageRect);
  2278. break;
  2279. }
  2280. }
  2281. }
  2282. //显示样品孔照片
  2283. IsShowSampleHoleImage = true;
  2284. Invalidate();
  2285. }
  2286. #endregion
  2287. #region 删除样品孔中BSE图像信息
  2288. public void DeleteHoleBSEImageDataNoMessageBox()
  2289. {
  2290. m_ImageOfFieldGDIObjects.Clear();
  2291. m_ImageGDIObjects.Clear();
  2292. Invalidate();
  2293. }
  2294. #endregion
  2295. #region 获取样品孔图片
  2296. private int GetSampleHoleIndex(StageDrawingData oTSSampleStageData, string sampleHoleName, ref OTSSampleHoleInfo sampleHoleInfo)
  2297. {
  2298. try
  2299. {
  2300. int sampleHoleIndex = -1;
  2301. if (oTSSampleStageData.sSHoleInfoList.Count > 0)
  2302. {
  2303. for (int i = 0; i < oTSSampleStageData.sSHoleInfoList.Count; i++)
  2304. {
  2305. if (oTSSampleStageData.sSHoleInfoList[i].sSHoleName == sampleHoleName)
  2306. {
  2307. sampleHoleInfo = oTSSampleStageData.sSHoleInfoList[i];
  2308. sampleHoleIndex = i;
  2309. break;
  2310. }
  2311. }
  2312. }
  2313. return sampleHoleIndex;
  2314. }
  2315. catch (Exception)
  2316. {
  2317. return -1;
  2318. }
  2319. }
  2320. public void GetBSEPictures()
  2321. {
  2322. OTSSampleHoleInfo sampleHoleInfo = null;
  2323. var index= GetSampleHoleIndex(m_visualStage.GetOTSSampleStageData(), m_SampleHoleSelectName, ref sampleHoleInfo);
  2324. if (sampleHoleInfo != null)
  2325. {
  2326. m_MeasureAppForm.StartSampleHoleBSEImage(index);
  2327. }
  2328. }
  2329. #endregion
  2330. #region 复位工作样品区域
  2331. public CRectangleGDIObject ResetMeasure( CRectangleGDIObject SampleGDIObjects, CRectangleGDIObject MeasureGDIObjects)
  2332. {
  2333. m_visualStage .GetMeasureGdiObjectFromSampleGdi(SampleGDIObjects,out MeasureGDIObjects);
  2334. return MeasureGDIObjects;
  2335. }
  2336. public void ResetWorkSampleMeasure()
  2337. {
  2338. COTSSample WSample = m_MeasureAppForm.m_ProjParam.GetWorkSample();
  2339. OTSSamplePropertyInfo MeasureInfo = new OTSSamplePropertyInfo();
  2340. if (!m_MeasureAppForm.m_ProjParam.GetWorkSamplePerameter(WSample, ref MeasureInfo))
  2341. {
  2342. return;
  2343. }
  2344. RectangleF measureSize = m_MeasureAppForm.m_ProjParam.CalculateMsrArea(MeasureInfo.SMeasurePara.sampleHoleName);
  2345. //获取位置与尺寸
  2346. MeasureInfo.SMeasurePara.MeasureRect.Location = measureSize.Location;
  2347. MeasureInfo.SMeasurePara.MeasureRect.Size = measureSize.Size;
  2348. //获取样品信息
  2349. PointF xHole = new PointF(MeasureInfo.SMeasurePara.MeasureRect.Left, MeasureInfo.SMeasurePara.MeasureRect.Top);
  2350. PointF yHole = new PointF(MeasureInfo.SMeasurePara.MeasureRect.Right, MeasureInfo.SMeasurePara.MeasureRect.Bottom);
  2351. //定义测量区域
  2352. RectangleF SampleRectangleF = m_visualStage.GetCtrlCoordRectF(xHole,yHole);
  2353. CRectangleGDIObject m_MeasureGDIObject = m_visualStage.GetCtrlCoordRect(xHole,yHole,(CreateRectangleType)MeasureInfo.SMeasurePara.iShape, "", "");
  2354. m_MeasureGDIObject.SetInitRegionF(SampleRectangleF);
  2355. var sam = GetWorkingVisualSample();
  2356. var mea = sam.GetMeasureGDIObject();
  2357. CRectangleGDIObject m_ResetMeasureGDIobjects = ResetMeasure( sam.GetSampleGDIObject(), m_MeasureGDIObject);
  2358. mea.SetInitRegionF(m_ResetMeasureGDIobjects.GetOrigionalDrawRegionF());
  2359. mea.Shape = m_ResetMeasureGDIobjects.Shape;
  2360. Invalidate();
  2361. }
  2362. #endregion
  2363. }
  2364. }