Control_DrawDistrbutionImageAndBSE.cs 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586
  1. using NLog;
  2. using OTSCommon.Model;
  3. using OTSIncAReportApp;
  4. using OTSIncAReportApp._3_ServiceCenter;
  5. using OTSIncAReportApp.DataOperation.DataAccess;
  6. using OTSIncAReportApp.OTSSampleReportInfo;
  7. using OTSIncAReportApp.SysMgrTools;
  8. using OTSIncAReportGraph.Class;
  9. using OTSIncAReportGraph.OTSIncAReportGraphFuncation;
  10. using OTSIncAReportMailInterface;
  11. using OTSPeriodicTable;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.Drawing;
  16. using System.Drawing.Drawing2D;
  17. using System.IO;
  18. using System.Linq;
  19. using System.Threading;
  20. using System.Windows.Forms;
  21. namespace OTSIncAReportGraph.Controls
  22. {
  23. public enum SelectedShape
  24. {
  25. Rectangle = 0,
  26. Ellipse = 1
  27. }
  28. public struct SelectTool
  29. {
  30. public SelectedShape Shape;
  31. public Point StartPoint;
  32. public bool IsSelecting;
  33. //进行选择的矩形范围
  34. public RectangleF Rect;
  35. }
  36. public struct ParticleSegmentation
  37. {
  38. public Point StartPoint;
  39. public bool IsParticleSegmentation;
  40. public Point EndPoint;
  41. public Particle ParticleData;
  42. public RectangleF Rectangle;
  43. }
  44. public enum RightButtonMenu
  45. {
  46. CopyImage = 0,
  47. OriginalSplicing = 1
  48. }
  49. /// <summary>
  50. /// 选择导出的图片是原图还是颗粒渲染后的图片
  51. /// </summary>
  52. public enum Outpic_enum
  53. {
  54. pic = 0,
  55. Render_pic = 1,
  56. noBackground_pic = 2,
  57. GBOne = 3,
  58. Combin,
  59. Render_Combin
  60. }
  61. public partial class Control_DrawDistrbutionImageAndBSE : UserControl
  62. {
  63. private OTSImageDisHelp imageDisHelper = null;
  64. //缩放的增大缩小的增量
  65. private const float const_zoom_increment = 0.05f;
  66. //最大缩放倍数
  67. private const float m_f_zoom_max = 4f;
  68. //最小缩放倍数
  69. private float m_f_zoom_mix = 0.05f;
  70. //标尺原先大小的记录,参与计算
  71. private float m_f_old_ruler_size = 100;
  72. double ls_d_cz_width;
  73. double ls_d_cz_height;
  74. #region 变量定义
  75. private SelectTool m_SelectTool;
  76. private ParticleSegmentation m_ParticleSegmentation;
  77. public bool isReView = false;
  78. public int reViewFieldId = 0;
  79. public int reViewParticleId = 0;
  80. //与原先缩放的记录数
  81. private float m_zoom_record = 1;
  82. //标尺的大小记录
  83. public float m_f_ruler_size = 100;
  84. public float m_pixelSize = 4.5f;
  85. //国际化存储信息
  86. System.Collections.Hashtable table;
  87. //包含particle的field的列表对象
  88. public List<DisplayField> m_list_allDfield = null;
  89. //这里要做成控件,不要是窗体
  90. public List<DisplayParticle> m_list_allDPart = null;
  91. public List<DisplayParticle> m_list_allDPart_original = null;
  92. public List<DisplayField> m_CurGBFields = new List<DisplayField>();
  93. //总背景矩形
  94. private RectangleF m_backRect = new RectangleF();
  95. private PointF m_ScaleRefPoint;
  96. //记录总物理矩形总大小
  97. public RectangleF m_back_wl_rectf = new RectangleF();
  98. //是否显示网格线
  99. private bool m_is_showgrid = false;
  100. //是否拖动
  101. private bool m_isDrag = false;
  102. //拖动前的坐标记录
  103. private PointF m_beforedrag_pointf = new PointF();
  104. //提供鼠标在右下角显示的文本,左侧
  105. private string m_str_mouseshow_left = "";
  106. //提供鼠标在右下角显示的文本,右侧
  107. private string m_str_mouseshow_right = "";
  108. //当前鼠标的位置
  109. Point m_mouse_now_point = new Point();
  110. Point m_currentMouseDownPoint;
  111. //记录当前鼠标位置对应SEM电镜的位置
  112. Point m_sem_mouse_now_point = new Point();
  113. //鼠标移动经过的颗粒对象,临时存放,用来记录是否要显示xray与隐藏xray
  114. DisplayParticle m_mouseOver_dparticle = null;
  115. //保存数据源名称
  116. private string m_showsourcename = "";
  117. //保存当前数据源的ID
  118. private int m_datasourceid = 0;
  119. //移动SEM到指定位置发生线程
  120. private Thread m_mythread;
  121. private Color m_ColorNotContent = Color.SkyBlue;
  122. //读取背景原图的名称和图片
  123. private Dictionary<string, Image> originalImages = new Dictionary<string, Image>();
  124. private DISTRIBUTION_IMAGE_SHOW_MODE showMode;
  125. static System.Windows.Forms.Timer delaytimer = new System.Windows.Forms.Timer();
  126. Logger log;
  127. public string ShowSourceName
  128. {
  129. set { m_showsourcename = value; }
  130. get { return m_showsourcename; }
  131. }
  132. /// <summary>
  133. /// 当前正在显示的数据源的ID
  134. /// </summary>
  135. public int DataSourceID
  136. {
  137. set { m_datasourceid = value; }
  138. get { return m_datasourceid; }
  139. }
  140. //进度条窗体
  141. public Frm_UserProgress m_frm_userprogress;
  142. OTSIncAReportApp.frmReportApp m_ReportApp;
  143. ResultFile resultFile = null;
  144. //private Cursor cursor1;
  145. #endregion
  146. #region 构造函数及窗体加载
  147. public Control_DrawDistrbutionImageAndBSE(OTSIncAReportApp.frmReportApp ReportApp)
  148. {
  149. log = NLog.LogManager.GetCurrentClassLogger();
  150. m_list_allDfield = new List<DisplayField>();
  151. m_list_allDPart = new List<DisplayParticle>();
  152. m_frm_userprogress = new Frm_UserProgress();
  153. //cursor1 = Cursor;
  154. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  155. m_ReportApp = ReportApp;
  156. resultFile = m_ReportApp.m_rstDataMgr.CurResultFile;
  157. InitializeComponent();
  158. #region 国际化语言
  159. Language lan = new Language(this);
  160. table = lan.GetNameTable(this.Name);
  161. #endregion
  162. //load the userdefine control dynamically
  163. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Control_DrawDistrbutionImageAndBSE));
  164. this.control_XRayTable1 = new Control_XRayTable();
  165. this.control_XRayTable1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
  166. this.control_XRayTable1.Dock = System.Windows.Forms.DockStyle.Bottom;
  167. this.control_XRayTable1.GBInfoStr = "";
  168. this.control_XRayTable1.GoodChineseName = "";
  169. this.control_XRayTable1.MaterialName = "";
  170. this.control_XRayTable1.List_ShowElementInfo = ((System.Collections.Generic.List<OTSIncAReportGraph.Controls.ShowElementInfo>)(resources.GetObject("control_XRayTable1.List_ShowElementInfo")));
  171. this.control_XRayTable1.Location = new System.Drawing.Point(0, 400);
  172. this.control_XRayTable1.Name = "control_XRayTable1";
  173. this.control_XRayTable1.ShowAnalysisXray = true;
  174. this.control_XRayTable1.ShowSearchXray = false;
  175. this.control_XRayTable1.Size = new System.Drawing.Size(1004, 200);
  176. this.control_XRayTable1.STDName = "";
  177. this.control_XRayTable1.TabIndex = 6;
  178. this.control_XRayTable1.Visible = false;
  179. //
  180. // control_Ruler1
  181. //
  182. this.control_Ruler1 = new Control_Ruler();
  183. this.control_Ruler1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
  184. this.control_Ruler1.Location = new System.Drawing.Point(3, 400);
  185. this.control_Ruler1.Name = "control_Ruler1";
  186. this.control_Ruler1.RulerWidth = 100;
  187. this.control_Ruler1.ShowString = "100um";
  188. this.control_Ruler1.Size = new System.Drawing.Size(120, 40);
  189. this.control_Ruler1.TabIndex = 8;
  190. this.control_Ruler1.Value = 0D;
  191. this.control_Ruler1.Visible = false;
  192. this.Controls.Add(this.control_XRayTable1);
  193. this.Controls.Add(this.control_Ruler1);
  194. }
  195. private void ProgressBarUpdate(int progress, string message)
  196. {
  197. //显示进度条,计算进度条应该显示的位置和宽度
  198. if (m_frm_userprogress.Visible == false)
  199. {
  200. Form ls_main_form = this.ParentForm.ParentForm;//取出父窗体
  201. m_frm_userprogress.Width = (int)(MyPrimaryScreen.DESKTOP.Width / MyPrimaryScreen.ScaleX * 0.9);
  202. m_frm_userprogress.Location = new Point(ls_main_form.Location.X + 80, ls_main_form.Location.Y + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
  203. m_frm_userprogress.Show();
  204. }
  205. m_frm_userprogress.SetProgressValueAndText(progress, message);
  206. }
  207. private void Control_DrawDistrbutionImageAndBSE_Load(object sender, EventArgs e)
  208. {
  209. //设置双缓冲
  210. SetDoubleBufferByIsDraw();
  211. ProgressBarUpdate(0, table["str1"].ToString());
  212. //初始化底层操作类
  213. imageDisHelper = new OTSImageDisHelp(resultFile);
  214. m_backRect = imageDisHelper.m_originalBackRect;
  215. string str29 = "begin to compose field picture....";
  216. log.Info(str29);
  217. ProgressBarUpdate(20, "compose whole picture....");
  218. List<Field> fieldlist = resultFile.List_OTSField;
  219. float ls_int_progresscalc = 0;
  220. if (fieldlist.Count > 0)
  221. ls_int_progresscalc = (float)70 / (float)fieldlist.Count;
  222. m_list_allDfield.Clear();
  223. m_list_allDPart.Clear();
  224. var fieldSize = imageDisHelper.GetFieldImageSize();
  225. for (int i = 0; i < fieldlist.Count(); i++)
  226. {
  227. ProgressBarUpdate(20 + (int)(ls_int_progresscalc * (i + 1)), "finished " + i.ToString() + "total " + resultFile.List_OTSField.Count.ToString() + "field...");
  228. Point thisfield_point = new Point() { X = fieldlist[i].FieldPosX, Y = fieldlist[i].FieldPosY };//get OTS coordination
  229. Point offset_point = imageDisHelper.ConvertOTSCoordToScreenCoord(thisfield_point);//the ots coordinate is always the up right positive.
  230. DisplayField df;
  231. try
  232. {
  233. df = new DisplayField(fieldlist[i], (int)fieldSize.Width, (int)fieldSize.Height, offset_point);
  234. df.ContentColor = Color.Black;
  235. m_list_allDfield.Add(df);
  236. m_list_allDPart.AddRange(df.List_DParticle);
  237. }
  238. catch (Exception ex)
  239. {
  240. NLog.LogManager.GetCurrentClassLogger().Info(ex.ToString());
  241. }
  242. }
  243. m_list_allDPart_original = new List<DisplayParticle>();
  244. foreach (var apart in m_ReportApp.im_Control_DrawDistrbutionImageAndBSE.m_list_allDPart)
  245. {
  246. m_list_allDPart_original.Add(apart.Clone() as DisplayParticle);
  247. }
  248. m_pixelSize = resultFile.GetPixelSize();
  249. //设置标尺
  250. //根据f_onepixel_size计算出要显示出100um的实际宽度
  251. float d_onefixel_width = 100 / m_pixelSize;
  252. if (d_onefixel_width == 0)
  253. {
  254. this.control_Ruler1.Visible = false;
  255. }
  256. else
  257. {
  258. m_f_ruler_size = d_onefixel_width;
  259. m_f_old_ruler_size = d_onefixel_width;
  260. //将标尺定位到合理的位置上
  261. this.control_Ruler1.Location = new Point(10, MyPrimaryScreen.WorkingArea.Height - 300);
  262. this.control_Ruler1.Visible = true;
  263. this.control_Ruler1.SetValue(m_f_ruler_size);
  264. this.control_Ruler1.ShowString = Convert.ToInt32(100).ToString() + "μm";
  265. }
  266. ProgressBarUpdate(100, table["str2"].ToString());
  267. m_frm_userprogress.Visible = false;
  268. if (m_ReportApp.im_ParticlesGridDevidePage != null)
  269. {
  270. m_ReportApp.im_ParticlesGridDevidePage.ToolStripMenuItem_Addparticlestotheselectparticleslist.Visible = true; //由于分布图和颗粒表数据来源相对独立,所以只能在这里激活颗粒表选择菜单,待日后修改数据源加载方式,此项需修改
  271. }
  272. }
  273. /// <summary>
  274. /// 分布图和BSE图中,从底层获取相关结果后,重新组织显示
  275. /// </summary>
  276. /// <param name="sourceGridData"></param>
  277. public void FilterParticleByOtherCondition(ReportCondition sourceGridData)
  278. {
  279. bool sizeconditionResult;
  280. bool stdIdconditionResult;
  281. string stdId = "";
  282. int stdIdIndex = 0;
  283. //find the stdId condition
  284. var STDIdItm = sourceGridData.ConditionItemList.Find(s => s.iItemId == OTS_REPORT_PROP_GRID_ITEMS.STD_ID);
  285. if (STDIdItm != null)
  286. {
  287. stdId = STDIdItm.itemDisplayVal.ToString();
  288. stdIdIndex = STDIdItm.comboDownList.IndexOf(stdId);
  289. }
  290. //find the size condition
  291. var size_cal_method_type = (SIZE_CAL_METHOD_TYPE)sourceGridData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE);
  292. var itm = sourceGridData.ConditionItemList.Find(s => s.iItemId == OTS_REPORT_PROP_GRID_ITEMS.GRAIN_SIZE_CLASS);
  293. string size = itm.itemDisplayVal.ToString();
  294. int index = itm.comboDownList.IndexOf(size);
  295. string min = "0";
  296. string max = "999";
  297. if (index > 0)
  298. {
  299. max = sourceGridData.ConditionItemList.Find(s => s.iItemId == OTS_REPORT_PROP_GRID_ITEMS.GRAIN_SIZE_MAX).itemDisplayVal.ToString();
  300. min = sourceGridData.ConditionItemList.Find(s => s.iItemId == OTS_REPORT_PROP_GRID_ITEMS.GRAIN_SIZE_MIN).itemDisplayVal.ToString();
  301. if (max.ToLower() == "max")
  302. {
  303. max = "999";
  304. }
  305. }
  306. double dia_min = Convert.ToDouble(min);
  307. double dia_max = Convert.ToDouble(max);
  308. foreach (DisplayParticle ls_dp in m_list_allDPart)
  309. {
  310. if (index > 0)
  311. {
  312. double diameter = 0;
  313. switch (size_cal_method_type)
  314. {
  315. case SIZE_CAL_METHOD_TYPE.DMAX:
  316. diameter = ls_dp.objParticleData.DMAX;
  317. break;
  318. case SIZE_CAL_METHOD_TYPE.DMIN:
  319. diameter = ls_dp.objParticleData.DMIN;
  320. break;
  321. case SIZE_CAL_METHOD_TYPE.CIRCLE:
  322. diameter = Math.Sqrt(ls_dp.objParticleData.Area / 3.14159f) * 2f;
  323. break;
  324. case SIZE_CAL_METHOD_TYPE.DFERET:
  325. diameter = ls_dp.objParticleData.DFERET;
  326. break;
  327. default:
  328. diameter = 0;
  329. break;
  330. }
  331. if (diameter >= dia_min && diameter <= dia_max)
  332. {
  333. sizeconditionResult = true;
  334. }
  335. else
  336. {
  337. sizeconditionResult = false;
  338. }
  339. }
  340. else
  341. {
  342. sizeconditionResult = true;
  343. }
  344. if (stdIdIndex > 0)// it's not "All"
  345. {
  346. if (ls_dp.objParticleData.TypeName != stdId)
  347. {
  348. stdIdconditionResult = false;
  349. }
  350. else
  351. {
  352. stdIdconditionResult = true;
  353. }
  354. }
  355. else
  356. {
  357. stdIdconditionResult = true;
  358. }
  359. if (stdIdconditionResult && sizeconditionResult)
  360. {
  361. ls_dp.SetDisplayState(DisplayState.DISPLAY);
  362. }
  363. else
  364. {
  365. ls_dp.SetDisplayState(DisplayState.NODISPLAY);
  366. }
  367. }
  368. }
  369. #endregion
  370. #region 设置双缓冲
  371. /// <summary>
  372. /// 设置双缓冲
  373. /// </summary>
  374. public void SetDoubleBufferByIsDraw()
  375. {
  376. SetStyle(ControlStyles.UserPaint, true); //没什么效果,开与关
  377. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景,关了闪
  378. SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 双缓冲,关了闪
  379. //上面是必须有的
  380. SetStyle(ControlStyles.UserMouse, true); //执行自己的鼠标行为,这个打开后,在win7下鼠标操作明显改善
  381. }
  382. #endregion
  383. #region 绘制函数
  384. protected override void OnPaint(PaintEventArgs e)//处理重绘情况
  385. {
  386. switch (showMode)
  387. {
  388. case DISTRIBUTION_IMAGE_SHOW_MODE.BSE:
  389. e.Graphics.FillRectangle(new SolidBrush(Color.Gainsboro), m_backRect);
  390. foreach (DisplayParticle dp in m_list_allDPart)
  391. {
  392. //dp.SetDisplayState(DisplayState.DISPLAY);
  393. dp.ShowMode = SegmentShowMode.DRAWPARTICLEIMAGE;
  394. if (dp.GetPaintState() != PaintState.NOPAINT)
  395. {
  396. dp.OnPaint(e);
  397. }
  398. }
  399. break;
  400. case DISTRIBUTION_IMAGE_SHOW_MODE.CLASSIFIED:
  401. e.Graphics.FillRectangle(new SolidBrush(Color.Gainsboro), m_backRect);
  402. foreach (DisplayParticle dp in m_list_allDPart)
  403. {
  404. dp.ShowMode = SegmentShowMode.DRAWLINE;
  405. if (dp.GetPaintState() != PaintState.NOPAINT)
  406. {
  407. dp.OnPaint(e);
  408. }
  409. }
  410. break;
  411. case DISTRIBUTION_IMAGE_SHOW_MODE.ORIGINAl:
  412. foreach (DisplayParticle ls_dp in m_list_allDPart)
  413. {
  414. ls_dp.SetDisplayState(DisplayState.NODISPLAY);
  415. }
  416. DrawOriginalImageAsBackground(e);
  417. break;
  418. case DISTRIBUTION_IMAGE_SHOW_MODE.ORIGINALCLASSIFIED:
  419. DrawOriginalImageAsBackground(e);
  420. foreach (DisplayParticle dp in m_list_allDPart)
  421. {
  422. dp.ShowMode = SegmentShowMode.DRAWLINE;
  423. if (dp.GetPaintState() != PaintState.NOPAINT)
  424. {
  425. dp.OnPaint(e);
  426. }
  427. }
  428. break;
  429. default:
  430. break;
  431. }
  432. //display GB field
  433. if (m_CurGBFields.Count > 0)
  434. {
  435. foreach (var f in m_CurGBFields)
  436. {
  437. f.OnPaint(e, Color.Red);
  438. }
  439. }
  440. #region 绘制网格线,帧图边框部份
  441. if (true == m_is_showgrid)
  442. {
  443. foreach (var fld in m_list_allDfield)
  444. {
  445. fld.OnPaint(e, Color.Black);
  446. }
  447. }
  448. #endregion
  449. #region //判断是否使用了矩形或圆形工具进行多选,是的话,那么这里就开始绘制------------------------
  450. if (m_SelectTool.IsSelecting)
  451. {
  452. if (m_SelectTool.Shape == SelectedShape.Rectangle && m_SelectTool.Rect.Width > 0 && m_SelectTool.Rect.Height > 0)
  453. {
  454. Graphics g = e.Graphics;
  455. //绘制矩形
  456. g.DrawRectangle(new Pen(Color.Blue), m_SelectTool.Rect.X, m_SelectTool.Rect.Y, m_SelectTool.Rect.Width, m_SelectTool.Rect.Height);
  457. //半透明画刷
  458. SolidBrush brush = new SolidBrush(Color.FromArgb(50, m_ColorNotContent));
  459. //填充选择矩形
  460. g.FillRectangle(brush, m_SelectTool.Rect.X, m_SelectTool.Rect.Y, m_SelectTool.Rect.Width, m_SelectTool.Rect.Height);
  461. }
  462. if (m_SelectTool.Shape == SelectedShape.Ellipse && m_SelectTool.Rect.Width > 0 && m_SelectTool.Rect.Height > 0)
  463. {
  464. Graphics g = e.Graphics;
  465. //绘制圆形
  466. g.DrawEllipse(new Pen(Color.Blue), m_SelectTool.Rect.X, m_SelectTool.Rect.Y, m_SelectTool.Rect.Width, m_SelectTool.Rect.Height);
  467. //半透明画刷
  468. SolidBrush brush = new SolidBrush(Color.FromArgb(50, m_ColorNotContent));
  469. //填充选择圆形
  470. g.FillEllipse(brush, m_SelectTool.Rect.X, m_SelectTool.Rect.Y, m_SelectTool.Rect.Width, m_SelectTool.Rect.Height);
  471. }
  472. }
  473. #endregion
  474. #region //判断是否使用颗粒分割,是的话,那么这里就开始绘制------------------------
  475. if (m_ParticleSegmentation.IsParticleSegmentation)
  476. {
  477. e.Graphics.DrawLine(new Pen(Color.Red), m_ParticleSegmentation.StartPoint.X, m_ParticleSegmentation.StartPoint.Y, m_ParticleSegmentation.EndPoint.X, m_ParticleSegmentation.EndPoint.Y);
  478. }
  479. #endregion
  480. #region 绘制鼠标跟踪线部份
  481. //XX虚线-----------------------------------------------
  482. Pen xxpen = new Pen(Color.GreenYellow, 1);
  483. xxpen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
  484. xxpen.DashPattern = new float[] { 5, 5 };
  485. //竖线
  486. e.Graphics.DrawLine(xxpen, 0, m_mouse_now_point.Y, m_mouse_now_point.X - 10, m_mouse_now_point.Y);
  487. e.Graphics.DrawLine(xxpen, m_mouse_now_point.X + 10, m_mouse_now_point.Y, this.Width, m_mouse_now_point.Y);
  488. //横线
  489. e.Graphics.DrawLine(xxpen, m_mouse_now_point.X, 0, m_mouse_now_point.X, m_mouse_now_point.Y - 10);
  490. e.Graphics.DrawLine(xxpen, m_mouse_now_point.X, m_mouse_now_point.Y + 10, m_mouse_now_point.X, this.Height);
  491. ////--------------------------------------------------------------------------------
  492. #endregion
  493. }
  494. #endregion
  495. #region 鼠标操作事件
  496. private void ImageZoom(float newZoom, PointF refPoint)
  497. {
  498. m_ScaleRefPoint = refPoint;
  499. float zoomDelta = newZoom - m_zoom_record;
  500. m_backRect.Width += m_backRect.Width / m_zoom_record * zoomDelta;
  501. m_backRect.Height += m_backRect.Height / m_zoom_record * zoomDelta;
  502. //锚点缩放补差值计算,得出差值
  503. float xShiftOld = (m_backRect.X - refPoint.X);
  504. float yShiftOld = (m_backRect.Y - refPoint.Y);
  505. float xShift = m_backRect.X - refPoint.X + xShiftOld / m_zoom_record * zoomDelta;
  506. float yShift = m_backRect.Y - refPoint.Y + yShiftOld / m_zoom_record * zoomDelta;
  507. //对背景矩形与所有的segment进行修补差值
  508. m_backRect.X = refPoint.X + xShift;
  509. m_backRect.Y = refPoint.Y + yShift;
  510. for (int i = 0; i < m_list_allDPart.Count(); i++)
  511. {
  512. DisplayParticle dp = m_list_allDPart[i];
  513. dp.Zoom(zoomDelta, refPoint);
  514. PointF ct = dp.GetCenterPoint();
  515. if (ct.X < -100 || ct.X > this.Width + 100 || ct.Y < -100 || ct.Y > this.Height + 100)
  516. {
  517. dp.SetPaintState(PaintState.NOPAINT);//the particles which are out of screen don't display.to speed up the display efficient.
  518. }
  519. }
  520. if (m_list_allDfield != null)
  521. {
  522. if (m_list_allDfield.Count > 0)
  523. {
  524. for (int i = 0; i < m_list_allDfield.Count; i++)
  525. {
  526. DisplayField theField = m_list_allDfield[i];
  527. theField.Zoom(zoomDelta, refPoint);
  528. }
  529. }
  530. }
  531. if (m_CurGBFields.Count > 0)
  532. {
  533. for (int i = 0; i < m_CurGBFields.Count; i++)
  534. {
  535. var r = m_CurGBFields[i];
  536. r.Zoom(zoomDelta, refPoint);
  537. }
  538. }
  539. #region 计算标尺尺寸部份-----放大------
  540. //计算标尺实际占用像素的宽度
  541. m_f_ruler_size = m_f_ruler_size + m_f_old_ruler_size * zoomDelta;//m_f_old_ruler_size
  542. control_Ruler1.SetValue(m_f_ruler_size);
  543. #endregion
  544. m_zoom_record = newZoom;
  545. if (m_zoom_record <= m_f_zoom_mix)
  546. {
  547. MoveImageToPoint(new PointF(0, 0));
  548. }
  549. }
  550. protected override void OnMouseWheel(MouseEventArgs e)
  551. {
  552. //float zoomDelta;
  553. float currentZoom;
  554. if (e.Delta > 0)
  555. {
  556. currentZoom = m_zoom_record + const_zoom_increment;
  557. }
  558. else
  559. {
  560. currentZoom = m_zoom_record - const_zoom_increment;
  561. }
  562. if (currentZoom > m_f_zoom_max) currentZoom = m_f_zoom_max;
  563. if (currentZoom < m_f_zoom_mix) currentZoom = m_f_zoom_mix;
  564. ImageZoom(currentZoom, new PointF(e.X, e.Y));
  565. Invalidate();
  566. }
  567. protected override void OnMouseDown(MouseEventArgs e)
  568. {
  569. if (e.Button == MouseButtons.Left)
  570. {
  571. this.Cursor = Cursors.Hand;
  572. isReView = false;
  573. if (m_SelectTool.IsSelecting)
  574. {
  575. m_SelectTool.StartPoint = e.Location;
  576. }
  577. else if (m_ParticleSegmentation.IsParticleSegmentation)
  578. {
  579. m_ParticleSegmentation.StartPoint = e.Location;
  580. }
  581. else
  582. {
  583. bool ifClickOnParticle = false;
  584. foreach (DisplayParticle item in m_list_allDPart)
  585. {
  586. var dp = item;
  587. if (imageDisHelper.WhetherInRange(dp, e.Location))
  588. {
  589. dp.IsSelect = !dp.IsSelect;
  590. ifClickOnParticle = true;
  591. break;
  592. }
  593. }
  594. if (ifClickOnParticle == false)
  595. {
  596. foreach (DisplayParticle dp in m_list_allDPart)
  597. {
  598. if (showMode == DISTRIBUTION_IMAGE_SHOW_MODE.ORIGINALCLASSIFIED)
  599. {
  600. dp.SetPaintState(PaintState.NOPAINT);
  601. }
  602. PointF ct = dp.GetCenterPoint();
  603. if (ct.X > -100 && ct.X < this.Width + 100 && ct.Y > -100 && ct.Y < this.Height + 100)
  604. {
  605. dp.IsDragging = true;
  606. }
  607. dp.DraggingPoint = e.Location;
  608. }
  609. foreach (DisplayField item in m_list_allDfield)
  610. {
  611. item.IsDragging = true;
  612. item.DraggingPoint = e.Location;
  613. }
  614. foreach (DisplayField item in m_CurGBFields)
  615. {
  616. item.IsDragging = true;
  617. item.DraggingPoint = e.Location;
  618. }
  619. m_isDrag = true;
  620. m_beforedrag_pointf = e.Location;
  621. }
  622. }
  623. }
  624. else
  625. {
  626. m_currentMouseDownPoint = e.Location;
  627. }
  628. Invalidate();
  629. }
  630. protected override void OnMouseMove(MouseEventArgs e)
  631. {
  632. //当前鼠标的位置,用来绘制鼠标线用
  633. m_mouse_now_point = e.Location;
  634. if (m_ParticleSegmentation.IsParticleSegmentation)
  635. {
  636. if (e.Button == MouseButtons.Left)
  637. {
  638. m_ParticleSegmentation.EndPoint = e.Location;
  639. }
  640. }
  641. if (m_SelectTool.IsSelecting)
  642. {
  643. if (e.Button == MouseButtons.Left)
  644. {
  645. if (e.Location.X > m_SelectTool.StartPoint.X && e.Location.Y > m_SelectTool.StartPoint.Y)
  646. {
  647. //右下拖动
  648. m_SelectTool.Rect = new RectangleF(m_SelectTool.StartPoint, new SizeF(e.Location.X - m_SelectTool.StartPoint.X, e.Location.Y - m_SelectTool.StartPoint.Y));
  649. }
  650. if (e.Location.X < m_SelectTool.StartPoint.X && e.Location.Y < m_SelectTool.StartPoint.Y)
  651. {
  652. //左上拖动
  653. PointF lspointf = new PointF(e.Location.X, e.Location.Y);
  654. m_SelectTool.Rect = new RectangleF(lspointf, new SizeF(m_SelectTool.StartPoint.X - e.Location.X, m_SelectTool.StartPoint.Y - e.Location.Y));
  655. }
  656. if (e.Location.X > m_SelectTool.StartPoint.X && e.Location.Y < m_SelectTool.StartPoint.Y)
  657. {
  658. //右上,这种画法,需要将左下,右上两点转换成左上,右下
  659. PointF left_pointf = new PointF(m_SelectTool.StartPoint.X, e.Location.Y);
  660. PointF right_pointf = new PointF(e.Location.X, m_SelectTool.StartPoint.Y);
  661. m_SelectTool.Rect = new RectangleF(left_pointf, new SizeF(right_pointf.X - left_pointf.X, right_pointf.Y - left_pointf.Y));
  662. }
  663. if (e.Location.X < m_SelectTool.StartPoint.X && e.Location.Y > m_SelectTool.StartPoint.Y)
  664. {
  665. //左下,这种画法,需要将左下,右上两点转换成左上,右下
  666. PointF left_pointf = new PointF(e.Location.X, m_SelectTool.StartPoint.Y);
  667. PointF right_pointf = new PointF(m_SelectTool.StartPoint.X, e.Location.Y);
  668. m_SelectTool.Rect = new RectangleF(left_pointf, new SizeF(right_pointf.X - left_pointf.X, right_pointf.Y - left_pointf.Y));
  669. }
  670. }
  671. }
  672. else
  673. {
  674. if (m_isDrag)
  675. {
  676. foreach (DisplayParticle dp in m_list_allDPart)
  677. {
  678. if (dp.IsDragging)
  679. {
  680. dp.DraggingMove(e.Location);
  681. }
  682. }
  683. foreach (var item in m_list_allDfield)
  684. {
  685. if (item.IsDragging)
  686. {
  687. item.DraggingMove(e.Location);
  688. }
  689. }
  690. foreach (var item in m_CurGBFields)
  691. {
  692. if (item.IsDragging)
  693. {
  694. item.DraggingMove(e.Location);
  695. }
  696. }
  697. //同样重新计算backrectf的坐标
  698. m_backRect = new RectangleF(m_backRect.Location.X + e.X - m_beforedrag_pointf.X,
  699. m_backRect.Location.Y + e.Y - m_beforedrag_pointf.Y, m_backRect.Width, m_backRect.Height);
  700. m_beforedrag_pointf = e.Location;
  701. }
  702. else
  703. {
  704. foreach (DisplayParticle item in m_list_allDPart)
  705. {
  706. DisplayParticle dp = item;
  707. if (dp.GetPaintState() == PaintState.PAINT)
  708. {
  709. if (imageDisHelper.WhetherInRange(dp, e.Location))
  710. {
  711. dp.IsMouseOver = true;
  712. ShowParticleInfo(dp);
  713. m_ParticleSegmentation.Rectangle = dp.GetShowRect();
  714. }
  715. else
  716. {
  717. dp.IsMouseOver = false;
  718. HideParticleInfo(dp);
  719. }
  720. }
  721. }
  722. }
  723. }
  724. #region 向报告程序右下角,传送鼠标颗粒等相关信息
  725. //获取颜色方法1,使用API来获取当前鼠标指向位置的颜色值-----------------------------------------------------
  726. Color ls_c = GetColorByMousePoint(e.X, e.Y);
  727. m_str_mouseshow_right = "灰度#" + ls_c.R.ToString();
  728. m_ReportApp.mouseMatter.Text = m_str_mouseshow_right;
  729. m_ReportApp.RSGrayVal.Text = m_str_mouseshow_left;
  730. #endregion
  731. Invalidate();
  732. }
  733. /// <summary>
  734. /// 计算颗粒中心的电镜坐标
  735. /// </summary>
  736. /// <param name="resultFile"></param>
  737. /// <param name="SEMPos"></param>
  738. /// <param name="ParticlePos"></param>
  739. /// <returns></returns>
  740. public static Point CalculateParticleCenterPosition(ResultFile resultFile, Point SEMPos, Point ParticlePos)
  741. {
  742. Point point = new Point();
  743. float ScanFieldSizeX = resultFile.GetScanFieldSizeX();
  744. string leftOrRight = resultFile.GetXAxisDir();
  745. string downOrUp = resultFile.GetYAxisDir();
  746. float ScanFieldSizeY = resultFile.GetScanFieldSizeY();
  747. float m_pixelSize = resultFile.GetPixelSize();
  748. if (leftOrRight == "RIGHT_TOWARD")
  749. {
  750. point.X = (int)(SEMPos.X - ScanFieldSizeX / 2 + ParticlePos.X * m_pixelSize);
  751. }
  752. else
  753. {
  754. point.X = (int)(SEMPos.X + ScanFieldSizeX / 2 - ParticlePos.X * m_pixelSize);
  755. }
  756. if (downOrUp == "UP_TOWARD")
  757. {
  758. point.Y = (int)(SEMPos.Y + ScanFieldSizeY / 2 - ParticlePos.Y * m_pixelSize);
  759. }
  760. else
  761. {
  762. point.Y = (int)(SEMPos.Y - ScanFieldSizeY / 2 + ParticlePos.Y * m_pixelSize);
  763. }
  764. return point;
  765. }
  766. /// <summary>
  767. /// 获取鼠标所在位置的信息,显示在框架的右下角
  768. /// </summary>
  769. /// <param name="mouseshow_left"></param>
  770. /// <param name="mouseshow_rightb"></param>
  771. public void GetMouseLowerRightCornerText(out string mouseshow_left, out string mouseshow_rightb)
  772. {
  773. mouseshow_left = m_str_mouseshow_left;
  774. mouseshow_rightb = m_str_mouseshow_right;
  775. }
  776. /// <summary>
  777. /// 鼠标抬起事件
  778. /// </summary>
  779. /// <param name="e"></param>
  780. protected override void OnMouseUp(MouseEventArgs e)
  781. {
  782. if (e.Button == MouseButtons.Left)
  783. {
  784. this.Cursor = Cursors.Default;
  785. if (m_SelectTool.IsSelecting)
  786. {
  787. if (m_SelectTool.Rect.Width > 0 && m_SelectTool.Rect.Height > 0)
  788. {
  789. GraphicsPath ls_gpath = new GraphicsPath();
  790. switch (m_SelectTool.Shape)
  791. {
  792. case SelectedShape.Rectangle:
  793. ls_gpath.AddRectangle(m_SelectTool.Rect);
  794. break;
  795. case SelectedShape.Ellipse:
  796. ls_gpath.AddEllipse(m_SelectTool.Rect);
  797. break;
  798. default:
  799. break;
  800. }
  801. foreach (DisplayParticle dp in m_list_allDPart)
  802. {
  803. if (dp.GetPaintState() != PaintState.NOPAINT)
  804. {
  805. PointF[] lspointf = ls_gpath.PathPoints;
  806. if (true == imageDisHelper.WhetherInRange(m_SelectTool.Rect, lspointf, new Point((int)dp.GetShowRect().X, (int)dp.GetShowRect().Y)))
  807. {
  808. //dp.IsSelect = !dp.IsSelect;// set the particle to the oposite selected state
  809. dp.IsSelect = true;//框选不应反选!
  810. }
  811. }
  812. }
  813. }
  814. m_SelectTool.IsSelecting = false;
  815. }
  816. else if (m_ParticleSegmentation.IsParticleSegmentation)
  817. {
  818. m_ParticleSegmentation.EndPoint = e.Location;
  819. DialogResult res = MessageBox.Show(table["str11"].ToString(), "", MessageBoxButtons.OKCancel);
  820. if (res == DialogResult.OK)
  821. {
  822. imageDisHelper.m_ParticleSegmentation = m_ParticleSegmentation;
  823. bool isTrue = imageDisHelper.isLineIntersectRectangle(m_ParticleSegmentation.StartPoint.X, m_ParticleSegmentation.StartPoint.Y, m_ParticleSegmentation.EndPoint.X, m_ParticleSegmentation.EndPoint.Y,
  824. m_ParticleSegmentation.Rectangle.Left, m_ParticleSegmentation.Rectangle.Top, m_ParticleSegmentation.Rectangle.Right, m_ParticleSegmentation.Rectangle.Bottom);
  825. if (isTrue)//判断绘制线段是否与颗粒外接矩形相交
  826. {
  827. List<Point> pointList = new List<Point>();
  828. if (imageDisHelper.GetInterBetweenLinesAndRect(m_ParticleSegmentation.StartPoint, m_ParticleSegmentation.EndPoint, m_ParticleSegmentation.Rectangle, ref pointList))
  829. {
  830. if (pointList.Count != 2)
  831. {
  832. MessageBox.Show(table["str12"].ToString());
  833. }
  834. else
  835. {
  836. if (!imageDisHelper.GetSplitPartFun(pointList[0], pointList[1], m_pixelSize))
  837. {
  838. MessageBox.Show(table["str13"].ToString());
  839. }
  840. else
  841. {
  842. FieldData fieldData = new FieldData(resultFile.FilePath);
  843. List<Field> fieldlist = fieldData.GetFieldList();
  844. m_ReportApp.m_rstDataMgr.CurResultFile.List_OTSField = fieldlist;
  845. m_ReportApp.rbRenewFun(true, m_ParticleSegmentation.ParticleData.FieldId, m_ParticleSegmentation.ParticleData.ParticleId);
  846. }
  847. }
  848. }
  849. }
  850. else
  851. {
  852. MessageBox.Show(table["str14"].ToString());
  853. }
  854. }
  855. m_ParticleSegmentation.IsParticleSegmentation = false;
  856. }
  857. else
  858. {
  859. if (m_isDrag)
  860. {
  861. foreach (DisplayParticle dp in m_list_allDPart)
  862. {
  863. dp.DraggingMove(e.Location);
  864. dp.DraggingPoint = Point.Empty;
  865. dp.IsDragging = false;
  866. PointF ct = dp.GetCenterPoint();
  867. if (ct.X < -100 || ct.X > this.Width + 100 || ct.Y < -100 || ct.Y > this.Height + 100)
  868. {
  869. dp.SetPaintState(PaintState.NOPAINT);//the particles which are out of screen don't display.to speed up the display efficient.
  870. }
  871. else
  872. {
  873. dp.SetPaintState(PaintState.PAINT);
  874. }
  875. }
  876. m_isDrag = false;
  877. }
  878. }
  879. SetParticlesSelected();
  880. }
  881. if (e.Button == MouseButtons.Right)
  882. {
  883. bool ifClickOnParticle = false;
  884. foreach (DisplayParticle item in m_list_allDPart)
  885. {
  886. if (true == imageDisHelper.WhetherInRange(item, e.Location))
  887. {
  888. ifClickOnParticle = true;
  889. CMenuStrip.Items[(int)RightButtonMenu.CopyImage].Visible = false;
  890. CMenuStrip.Items[(int)RightButtonMenu.OriginalSplicing].Visible = false;
  891. contextMenuStrip_Particle.Visible = true;
  892. contextMenuStrip_Particle.Show(this, e.Location);
  893. ToolStripMenuItem_movesempoint.Tag = item;
  894. DisplayParticle dp = (DisplayParticle)item;
  895. m_ParticleSegmentation.ParticleData = dp.objParticleData;
  896. }
  897. }
  898. if (ifClickOnParticle == false)
  899. {
  900. contextMenuStrip_Particle.Visible = false;
  901. CMenuStrip.Items[(int)RightButtonMenu.CopyImage].Visible = true;
  902. CMenuStrip.Items[(int)RightButtonMenu.OriginalSplicing].Visible = true;
  903. }
  904. var m_RptConfigFile = RptConfigFile.GetRptConfig(); //报表程序的配置文件
  905. if (m_RptConfigFile.Systype == OTS_SysType_ID.CleannessA)
  906. {
  907. 显示国标信息ToolStripMenuItem.Visible = false;
  908. }
  909. }
  910. Invalidate();
  911. }
  912. #endregion
  913. #region 鼠标右键菜单
  914. private void ToolStripMenuItem_id_Click(object sender, EventArgs e)
  915. {
  916. //ID
  917. //DisplayParticle dp = (DisplayParticle)CMenuStrip.Items[0].Tag;
  918. //MessageBox.Show(dp.guid.ToString());
  919. }
  920. //是否显示过小颗菜单
  921. private void ToolStripMenuItem_ShowSmallParticle_Click(object sender, EventArgs e)
  922. {
  923. }
  924. void SetParticlesSelected()
  925. {
  926. List<DisplayParticle> selectedParts = new List<DisplayParticle>();
  927. List<Particle> Particles = new List<Particle>();
  928. foreach (var dp in m_list_allDPart)
  929. {
  930. if (dp.IsSelect)
  931. {
  932. selectedParts.Add((DisplayParticle)dp);
  933. Particle particle = new Particle();
  934. particle.FieldId = ((OTSIncAReportGraph.DisplayParticle)dp).FieldId;
  935. particle.ParticleId = ((OTSIncAReportGraph.DisplayParticle)dp).ParticleId;
  936. Particles.Add(particle);
  937. }
  938. }
  939. SendSelectParticleListToReportFrame(selectedParts);
  940. }
  941. /// <summary>
  942. /// 显示x-ray能谱图
  943. /// </summary>
  944. /// <param name="in_dparticle"></param>
  945. private void ShowParticleInfo(DisplayParticle in_dparticle)
  946. {
  947. if (delaytimer.Enabled == false)
  948. {
  949. m_mouseOver_dparticle = in_dparticle;//将显示xray的dparticle记录给全局变量
  950. delaytimer.Tick += Delaytimer_Tick;
  951. delaytimer.Interval = 500;
  952. delaytimer.Start();
  953. }
  954. }
  955. private void Delaytimer_Tick(object sender, EventArgs e)
  956. {
  957. delaytimer.Enabled = false;
  958. Point point = CalculateParticleCenterPosition(resultFile, new Point(m_mouseOver_dparticle.SEMPosX, m_mouseOver_dparticle.SEMPosY), new Point(m_mouseOver_dparticle.objParticleData.PosX, m_mouseOver_dparticle.objParticleData.PosY));
  959. m_str_mouseshow_left = "颗粒SEM位置:" + point.X.ToString() + ":" + point.Y.ToString();
  960. m_sem_mouse_now_point = point;
  961. //显示xray相关信息
  962. uint[] Search_xray = new uint[2000];
  963. uint[] Analysis_xray = new uint[2000];
  964. //
  965. int i_xray_id = 0;
  966. List<Element> list_celementchemistryclr = new List<Element>();
  967. //获取Xray数据
  968. imageDisHelper.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(m_mouseOver_dparticle.ParticleId, m_mouseOver_dparticle.FieldId, out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
  969. //get CElementChemistryClr list
  970. List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
  971. for (int i = 0; i < list_celementchemistryclr.Count; i++)
  972. {
  973. ShowElementInfo ls_sei = new ShowElementInfo();
  974. ls_sei.ElementName = list_celementchemistryclr[i].Name;
  975. ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
  976. ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
  977. double de_sx2 = 0;
  978. if (CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "" || CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "-")
  979. {
  980. de_sx2 = 0;
  981. }
  982. else
  983. {
  984. de_sx2 = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak);
  985. }
  986. ls_sei.dLF = de_sx2;
  987. list_showelementinfo.Add(ls_sei);
  988. }
  989. string str_IncAName = "";
  990. str_IncAName = m_mouseOver_dparticle.TypeName;
  991. Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == m_mouseOver_dparticle.FieldId).ParticleList.Find(x => x.ParticleId == m_mouseOver_dparticle.ParticleId);
  992. control_XRayTable1.SetParticleInfo("Area:" + Math.Round(particle.Area, 2) + " " + "DELONG:" + Math.Round(particle.DELONG, 2) + " " + "DFERET:" + Math.Round(particle.DFERET, 2) + " " + "DINSCR:" + Math.Round(particle.DINSCR, 2) + " " + "DMAX:" + Math.Round(particle.DMAX, 2) + "\n" + "DMEAN:" + Math.Round(particle.DMEAN, 2) + " " + "DMIN:" + Math.Round(particle.DMIN, 2) + " " + "DPERP:" + Math.Round(particle.DPERP, 2) + " " + "ORIENTATION:" + Math.Round(particle.ORIENTATION, 2) + " " + "PERIMETER:" + Math.Round(particle.PERIMETER, 2));
  993. //获取数据后,需要对xraytable设置
  994. control_XRayTable1.Visible = true;
  995. control_XRayTable1.SetXRayShowLineValue(Search_xray, Analysis_xray, list_showelementinfo);
  996. //颗粒国标信息
  997. control_XRayTable1.GBInfoStr = "";
  998. control_XRayTable1.MaterialName = str_IncAName;//杂夹物
  999. control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
  1000. Invalidate();
  1001. }
  1002. /// <summary>
  1003. /// 隐藏x-ray能谱图
  1004. /// </summary>
  1005. private void HideParticleInfo(DisplayParticle in_dparticle)
  1006. {
  1007. if (m_mouseOver_dparticle == null)
  1008. return;
  1009. if (m_mouseOver_dparticle.guid == in_dparticle.guid || m_mouseOver_dparticle.IsDeleted == true)
  1010. {
  1011. //如果是刚才移动过的颗粒的话,那么这里再对xray进行隐藏
  1012. control_XRayTable1.Visible = false;
  1013. delaytimer.Enabled = false;
  1014. }
  1015. }
  1016. /// <summary>
  1017. /// 根据传入的鼠标位置,来获取当前鼠标位置上的灰度值
  1018. /// </summary>
  1019. /// <param name="int_x"></param>
  1020. /// <param name="int_y"></param>
  1021. /// <returns></returns>
  1022. private Color GetColorByMousePoint(int int_x, int int_y)
  1023. {
  1024. Graphics g = Graphics.FromHwnd(this.Handle);
  1025. IntPtr hdc = g.GetHdc();
  1026. uint u_color = 0;
  1027. try
  1028. {
  1029. u_color = DrawFunction.GetPixel(hdc, int_x, int_y);
  1030. }
  1031. catch
  1032. { }
  1033. Color ls_c = Color.FromArgb
  1034. (
  1035. (int)(u_color << 24 >> 24),
  1036. (int)(u_color << 16 >> 24),
  1037. (int)(u_color << 8 >> 24)
  1038. );
  1039. return ls_c;
  1040. }
  1041. /// <summary>
  1042. /// 封装,将分布图中的颗粒list传送给报告项目框架中
  1043. /// </summary>
  1044. private void SendSelectParticleListToReportFrame(List<DisplayParticle> selectParts)
  1045. {
  1046. frmReportApp.selectedParticles.Clear();
  1047. foreach (var p in selectParts)
  1048. {
  1049. frmReportApp.selectedParticles.Add(p.guid, p);
  1050. }
  1051. }
  1052. /// <summary>
  1053. /// 设置当前对哪些颗粒进行设置为选择状态
  1054. /// </summary>
  1055. /// <param name="in_list_cotsparticleclr"></param>
  1056. public void SetSelectParticle(List<Particle> particles)
  1057. {
  1058. if (particles == null)
  1059. {
  1060. return;
  1061. }
  1062. if (particles.Count == 0)
  1063. {
  1064. return;
  1065. }
  1066. foreach (DisplayParticle ls_dp in m_list_allDPart)
  1067. {
  1068. if (ls_dp.GetPaintState() == PaintState.PAINT)
  1069. {
  1070. for (int i = 0; i < particles.Count; i++)
  1071. {
  1072. if (particles[i].ParticleId == ls_dp.ParticleId
  1073. && particles[i].FieldId == ls_dp.FieldId)
  1074. {
  1075. ls_dp.IsSelect = true;
  1076. }
  1077. }
  1078. }
  1079. }
  1080. }
  1081. //复制图像
  1082. private void toolStripMenuItem_copyimage_Click(object sender, EventArgs e)
  1083. {
  1084. SaveFileDialog sfd = new SaveFileDialog();
  1085. sfd.Filter = "png Files(*.png)| *.png |BMP Files(*.bmp)| *.bmp |JPG Files(*.jpg)|*.jpg;*.jpeg";
  1086. if (sfd.ShowDialog() == DialogResult.OK)
  1087. {
  1088. this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
  1089. OutPIC outpic = new OutPIC();
  1090. outpic.m_list_allDfield = m_list_allDfield;
  1091. outpic.resultFile = resultFile;
  1092. outpic.sfd = sfd;
  1093. outpic.type = (int)Outpic_enum.pic;
  1094. outpic.m_ReportApp = m_ReportApp;
  1095. Thread bThread = new Thread(new ThreadStart(outpic.opencv_outpic));
  1096. bThread.IsBackground = true;
  1097. bThread.Start();
  1098. }
  1099. }
  1100. public void msgInform()
  1101. {
  1102. MessageBox.Show("Export completed!");
  1103. this.Cursor = System.Windows.Forms.Cursors.Default;
  1104. }
  1105. private void ToolStripMenuItem_movesempoint_Click(object sender, EventArgs e)
  1106. {
  1107. //移动SEM到指定位置
  1108. if (m_mythread == null)
  1109. {
  1110. return;
  1111. }
  1112. if (m_mythread.ThreadState == System.Threading.ThreadState.Running || m_mythread.ThreadState == System.Threading.ThreadState.WaitSleepJoin)
  1113. {
  1114. return;
  1115. }
  1116. if (m_mythread.ThreadState == System.Threading.ThreadState.Stopped)
  1117. {
  1118. m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
  1119. }
  1120. //改为线程调用,先判断线程状态
  1121. m_mythread.Start(new Point(m_sem_mouse_now_point.X, m_sem_mouse_now_point.Y));
  1122. }
  1123. #endregion
  1124. #region 自定义功能函数
  1125. /// <summary>
  1126. /// 复制图像
  1127. /// </summary>
  1128. private void CopyImage()
  1129. {
  1130. int height, width;
  1131. width = this.Width;
  1132. height = this.Height;
  1133. Bitmap image = new Bitmap(width, height);
  1134. //this.BackgroundImage
  1135. this.DrawToBitmap(image, new Rectangle(0, 0, width, height));
  1136. Clipboard.SetImage(image);
  1137. }
  1138. /// <summary>
  1139. /// 移动SEM到指定位置线程函数
  1140. /// </summary>
  1141. private void Thread_GO(object in_obj)
  1142. {
  1143. Point sem_point = (Point)in_obj;
  1144. //第二步,移动到指定位置,先读取再设置
  1145. if (imageDisHelper.ConnectToIpcSvr())
  1146. {
  1147. imageDisHelper.MoveSemToPointXY(sem_point.X, sem_point.Y);
  1148. }
  1149. }
  1150. /// <summary>
  1151. /// 按框架传入的底层计算结果,重新对颗粒进行区分显示
  1152. /// </summary>
  1153. /// <param name="in_cgriddataclr"></param>
  1154. public void DrawDistrbutionImageAndBSE_ByQuery(ReportCondition in_griddata)
  1155. {
  1156. FilterParticleByOtherCondition(in_griddata);
  1157. Invalidate();
  1158. this.Refresh();
  1159. }
  1160. /// <summary>
  1161. /// 对分布图进行宽度匹配操作
  1162. /// </summary>
  1163. public void WidthMatch()
  1164. {
  1165. if (this.Width != m_backRect.Width)
  1166. {
  1167. float f_cz = 0;//进行调整的差值
  1168. f_cz = -((m_backRect.Width - this.Width) / m_backRect.Width);
  1169. var theZoom = m_zoom_record + m_zoom_record * f_cz;//更新上缩放值,与下面处理缩放对应上
  1170. ImageZoom(theZoom, new PointF(0, 0));
  1171. }
  1172. MoveImageToPoint(new PointF(0, 0));
  1173. }
  1174. /// <summary>
  1175. /// 对分布图进行高度匹配操作
  1176. /// </summary>
  1177. public void HeightMatch()
  1178. {
  1179. if (this.Height != m_backRect.Height)
  1180. {
  1181. float f_cz = 0;//进行调整的差值
  1182. f_cz = -((m_backRect.Height - this.Height) / m_backRect.Height);
  1183. var currentZoom = m_zoom_record + f_cz;//更新上缩放值,与下面处理缩放对应上
  1184. ImageZoom(currentZoom, new PointF(0, 0));
  1185. }
  1186. //移动到,this.width - backrectf.width /2
  1187. int ls_x = (int)(this.Width - m_backRect.Width) / 2;
  1188. MoveImageToPoint(new PointF(ls_x, 0));
  1189. }
  1190. /// <summary>
  1191. /// 对分布图进行全图匹配操作
  1192. /// </summary>
  1193. public void FullGraphMatch()
  1194. {
  1195. //全图匹配,首先要判断出来是按宽度来计算缩放,还是按高度来计算缩放
  1196. double thiswidth = this.Width;
  1197. double thisheight = this.Height;
  1198. double imagewidth = m_backRect.Width;
  1199. double imageheight = m_backRect.Height;
  1200. //如果宽已相等rect在thisheight范围内,是宽度匹配已经达到目的,或是高已相等rect在thiswidth范围内,是高度匹配已经达到目的
  1201. if ((thiswidth == imagewidth && thisheight > imagewidth) || (thisheight == imageheight && thiswidth > imagewidth))
  1202. {
  1203. //已经达到目的不操作,返回
  1204. return;
  1205. }
  1206. //判断当前是否宽度匹配未达到全图匹配效果
  1207. if (thiswidth == imagewidth && thisheight < imageheight)
  1208. {
  1209. //说明目前已经达到了宽度匹配,但是未能显示完全整图需要高度匹配
  1210. HeightMatch();
  1211. m_f_zoom_mix = m_zoom_record;
  1212. return;
  1213. }
  1214. //判断当前是否高度匹配未达到全图匹配效果
  1215. if (thisheight == imageheight && thiswidth < imagewidth)
  1216. {
  1217. //说明目前已经达到了高度匹配,但是未能显示完全的整图需要宽度匹配
  1218. WidthMatch();
  1219. m_f_zoom_mix = m_zoom_record;
  1220. return;
  1221. }
  1222. ls_d_cz_width = Math.Abs(thiswidth / imagewidth);
  1223. ls_d_cz_height = Math.Abs(thisheight / imageheight);
  1224. //应该是看谁差的倍数大就按谁的进行调整,而不只能看高宽的差值
  1225. if ((1 - ls_d_cz_width) > (1 - ls_d_cz_height))
  1226. {
  1227. //宽差大,就调用WidthMate
  1228. WidthMatch();
  1229. }
  1230. else
  1231. {
  1232. //高差大,则调用HightMate
  1233. HeightMatch();
  1234. }
  1235. m_f_zoom_mix = m_zoom_record;
  1236. }
  1237. /// <summary>
  1238. /// 将整个图像的位置移动到指定的位置上
  1239. /// </summary>
  1240. private void MoveImageToPoint(PointF in_pointf)
  1241. {
  1242. SizeF offex_p = new SizeF(m_backRect.X - in_pointf.X, m_backRect.Y - in_pointf.Y);
  1243. //同样重新计算backrectf的坐标
  1244. m_backRect = new RectangleF(in_pointf.X, in_pointf.Y,
  1245. m_backRect.Width, m_backRect.Height);
  1246. for (int i = 0; i < m_list_allDPart.Count; i++)
  1247. {
  1248. DisplayParticle dp = m_list_allDPart[i];
  1249. dp.Move(offex_p);
  1250. PointF ct = dp.GetCenterPoint();
  1251. if (ct.X < -100 || ct.X > this.Width + 100 || ct.Y < -100 || ct.Y > this.Height + 100)
  1252. {
  1253. dp.SetPaintState(PaintState.NOPAINT);//the particles which are out of screen don't display.to speed up the display efficient.
  1254. }
  1255. else
  1256. {
  1257. dp.SetPaintState(PaintState.PAINT);
  1258. }
  1259. }
  1260. for (int i = 0; i < m_list_allDfield.Count; i++)
  1261. {
  1262. var f = m_list_allDfield[i];
  1263. f.Move(offex_p);
  1264. }
  1265. for (int i = 0; i < m_CurGBFields.Count; i++)
  1266. {
  1267. var f = m_CurGBFields[i];
  1268. f.Move(offex_p);
  1269. }
  1270. Invalidate();
  1271. }
  1272. /// <summary>
  1273. /// 是否显示边框格线,自动切换显示与不显示
  1274. /// </summary>
  1275. /// <param name="b_show"></param>
  1276. public void ShowGridLine()
  1277. {
  1278. m_is_showgrid = !m_is_showgrid;
  1279. }
  1280. /// <summary>
  1281. /// 是否显示标尺控件
  1282. /// </summary>
  1283. /// <param name="b_show"></param>
  1284. public void ShowRulerControl()
  1285. {
  1286. control_Ruler1.Visible = !control_Ruler1.Visible;
  1287. }
  1288. /// <summary>
  1289. /// 是否显示边框格线,带参重载
  1290. /// </summary>
  1291. /// <param name="b_show"></param>
  1292. public void ShowGridLine(bool b_show)
  1293. {
  1294. m_is_showgrid = b_show;
  1295. }
  1296. /// <summary>
  1297. /// 是否显示标尺控件,带参重载
  1298. /// </summary>
  1299. /// <param name="b_show"></param>
  1300. public void ShowRulerControl(bool b_show)
  1301. {
  1302. control_Ruler1.Visible = b_show;
  1303. }
  1304. /// <summary>
  1305. /// 颗粒分割
  1306. /// </summary>
  1307. public void Particle_Segmentation()
  1308. {
  1309. m_ParticleSegmentation.IsParticleSegmentation = true;
  1310. m_ParticleSegmentation.StartPoint = new Point();
  1311. m_ParticleSegmentation.EndPoint = new Point();
  1312. }
  1313. /// <summary>
  1314. /// 是否进行矩形多选操作
  1315. /// </summary>
  1316. public void MultiSelect_Rectangle()
  1317. {
  1318. m_SelectTool.IsSelecting = true;
  1319. m_SelectTool.Shape = SelectedShape.Rectangle;
  1320. m_SelectTool.Rect = new RectangleF();
  1321. m_SelectTool.Rect.Width = 0;
  1322. m_SelectTool.Rect.Height = 0;
  1323. }
  1324. /// <summary>
  1325. /// 是否进行圆形多选操作
  1326. /// </summary>
  1327. public void MultiSelect_Ellipse()
  1328. {
  1329. m_SelectTool.IsSelecting = true;
  1330. m_SelectTool.Shape = SelectedShape.Ellipse;
  1331. m_SelectTool.Rect = new RectangleF();
  1332. m_SelectTool.Rect.Width = 0;
  1333. m_SelectTool.Rect.Height = 0;
  1334. }
  1335. /// <summary>
  1336. /// 对选择的多边形进行反选操作
  1337. /// </summary>
  1338. public void ReverseSelection()
  1339. {
  1340. foreach (DisplayParticle dp in m_list_allDPart)
  1341. {
  1342. if (dp.IsSelect)
  1343. {
  1344. dp.IsSelect = false;
  1345. }
  1346. else
  1347. {
  1348. dp.IsSelect = true;
  1349. }
  1350. }
  1351. this.Invalidate();
  1352. }
  1353. /// <summary>
  1354. /// 取消所有的颗粒的选择状态
  1355. /// </summary>
  1356. public void DeselectAllParticle()
  1357. {
  1358. foreach (DisplayParticle dp in m_list_allDPart)
  1359. {
  1360. dp.IsSelect = false;
  1361. }
  1362. this.Invalidate();
  1363. }
  1364. /// <summary>
  1365. /// 将整个图像拷贝到内存中
  1366. /// </summary>
  1367. public void CopyToBitmap()
  1368. {
  1369. Bitmap bp = new Bitmap(this.Size.Width, this.Size.Height);
  1370. this.DrawToBitmap(bp, new Rectangle(0, 0, this.Size.Width, this.Size.Height));
  1371. Clipboard.SetImage(bp);
  1372. }
  1373. /// <summary>
  1374. /// 设置显示BSE原图,还是显示分布图带有标准库的
  1375. /// </summary>
  1376. public void SetShowMode(DISTRIBUTION_IMAGE_SHOW_MODE a_type)
  1377. {
  1378. showMode = a_type;
  1379. this.Invalidate();
  1380. }
  1381. /// <summary>
  1382. /// 根据传入的颗粒状态,来获取所有该颗粒状态下的数据,用来测试统计使用
  1383. /// </summary>
  1384. /// <param name="str_particlestate"></param>
  1385. /// <returns></returns>
  1386. public int GetParticleNumberByState(PaintState in_ParticleState)
  1387. {
  1388. int icount = 0;
  1389. foreach (DisplayParticle ls_dp in m_list_allDPart)
  1390. {
  1391. if (ls_dp.GetPaintState() == in_ParticleState)
  1392. {
  1393. icount++;
  1394. }
  1395. }
  1396. return icount;
  1397. }
  1398. /// <summary>
  1399. /// 获取所有原图
  1400. /// </summary>
  1401. /// <param name="args"></param>
  1402. /// <returns></returns>
  1403. private void DrawOriginalImageAsBackground(PaintEventArgs args)
  1404. {
  1405. foreach (var f in m_list_allDfield)
  1406. {
  1407. var curfldrec = f.GetShowRect();
  1408. if (curfldrec.Left > -2000 && curfldrec.Right < this.Width + 2000 && curfldrec.Top > -2000 && curfldrec.Bottom < this.Height + 2000)
  1409. {
  1410. args.Graphics.DrawImage(f.OriginalImage, curfldrec.X, curfldrec.Y, curfldrec.Width, curfldrec.Height);
  1411. if (curfldrec.Width > this.Width)// only when zoom to a certain magnification do we display the xray Positon point as "+"
  1412. {
  1413. Graphics g = args.Graphics;
  1414. for (int i = 0; i < f.List_DParticle.Count; i++)
  1415. {
  1416. PointF xrayPos = new PointF(f.List_DParticle[i].objParticleData.PosX, f.List_DParticle[i].objParticleData.PosY);
  1417. PointF p = new PointF(xrayPos.X / f.OriginalImage.Width * curfldrec.Width + curfldrec.X, xrayPos.Y / f.OriginalImage.Height * curfldrec.Height + curfldrec.Y);
  1418. g.DrawString("+", new Font("黑体", 6), new SolidBrush(Color.Red), p);
  1419. }
  1420. }
  1421. }
  1422. }
  1423. }
  1424. #endregion
  1425. private void ExportoriginalspliceToolStripMenuItem_Click(object sender, EventArgs e)
  1426. {
  1427. SaveFileDialog sfd = new SaveFileDialog();
  1428. var particledata = new ParticleData(resultFile.FilePath);
  1429. DataTable ParticleAll = particledata.GetParticleTypeInformation();
  1430. DataTable ParticleClass = particledata.GetParticleClassAll();
  1431. //|ALL Files(*.*)|*.*
  1432. //BMP Files(*.bmp)| *.bmp |
  1433. sfd.Filter = "png Files(*.png)| *.png |BMP Files(*.bmp)| *.bmp |JPG Files(*.jpg)|*.jpg;*.jpeg";
  1434. if (sfd.ShowDialog() == DialogResult.OK)
  1435. {
  1436. this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
  1437. OutPIC outpic = new OutPIC();
  1438. outpic.m_list_allDfield = m_list_allDfield;
  1439. outpic.resultFile = resultFile;
  1440. outpic.sfd = sfd;
  1441. outpic.type = (int)Outpic_enum.Render_pic;
  1442. outpic.ParticleData = ParticleAll.Copy();
  1443. outpic.ParticleClassData = ParticleClass.Copy();
  1444. outpic.m_ReportApp = m_ReportApp;
  1445. Thread bThread = new Thread(new ThreadStart(outpic.opencv_outpic));
  1446. bThread.IsBackground = true;
  1447. bThread.Start();
  1448. }
  1449. }
  1450. private void ToolStripMenuItemDelete_Particle_Click(object sender, EventArgs e)
  1451. {
  1452. DialogResult dr = MessageBox.Show("Remove all these particles permanently?", "Tips", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1453. if (dr == DialogResult.OK)
  1454. {
  1455. foreach (var p in m_list_allDPart)
  1456. {
  1457. if (p.IsSelect)
  1458. {
  1459. DeleteParticlesFromLibrary(p.objParticleData.ParticleId, p.objParticleData.FieldId);
  1460. p.IsDeleted = true;
  1461. }
  1462. }
  1463. MessageBox.Show("Deleted successfully");
  1464. Invalidate();
  1465. }
  1466. else
  1467. {
  1468. return;
  1469. }
  1470. }
  1471. public void DeletesParticlesSynchronously(List<Particle> list_Part)
  1472. {
  1473. foreach (var p in m_list_allDPart)
  1474. {
  1475. foreach (var p_Selected in list_Part)
  1476. {
  1477. if (p.ParticleId == p_Selected.ParticleId && p.FieldId == p_Selected.FieldId)
  1478. {
  1479. p.IsDeleted = true;
  1480. break;
  1481. }
  1482. }
  1483. }
  1484. Invalidate();
  1485. }
  1486. private bool DeleteParticlesFromLibrary(int in_clr_tagid, int in_clr_fieldid)
  1487. {
  1488. bool DoesItExist = false;
  1489. for (int i = 1; i < 201; i++)
  1490. {
  1491. if (System.IO.Directory.Exists(resultFile.FilePath + "\\FIELD_FILES\\Backups" + i.ToString()))
  1492. {
  1493. DoesItExist = true;
  1494. break;
  1495. }
  1496. }
  1497. if (!DoesItExist)
  1498. {
  1499. //备份数据库 ,.
  1500. BackupDatabase();
  1501. }
  1502. DoesItExist = false;
  1503. //防止为空校验判断
  1504. if (resultFile.List_OTSField == null)
  1505. return false;
  1506. Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
  1507. if (new ParticleData(resultFile.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
  1508. {
  1509. return true;
  1510. }
  1511. else
  1512. {
  1513. return false;
  1514. }
  1515. }
  1516. public bool WhetherThereAreDeleteParticles()
  1517. {
  1518. foreach (var p in m_list_allDPart)
  1519. {
  1520. if (p.IsDeleted)
  1521. {
  1522. return true;
  1523. }
  1524. }
  1525. return false;
  1526. }
  1527. private bool BackupDatabase()
  1528. {
  1529. //创建备份数据库文件夹
  1530. string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
  1531. string sourceName = "Inclusion.db";//源文件名称
  1532. string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
  1533. string Fields = "";
  1534. for (int i = 1; i < 201; i++)
  1535. {
  1536. if (System.IO.Directory.Exists(folderPath + i.ToString()))
  1537. {
  1538. Fields = folderPath + i.ToString();
  1539. continue;
  1540. }
  1541. else
  1542. {
  1543. System.IO.Directory.CreateDirectory(folderPath + i.ToString());
  1544. Fields = folderPath + i.ToString();
  1545. break;
  1546. }
  1547. }
  1548. if (Fields == "")
  1549. {
  1550. return false;
  1551. }
  1552. //复制数据库文件
  1553. string targetPath = Path.Combine(Fields, sourceName);
  1554. FileInfo file = new FileInfo(sourcePath);
  1555. if (file.Exists)
  1556. {
  1557. file.CopyTo(targetPath, true);
  1558. }
  1559. return true;
  1560. }
  1561. int GetsIntersectionOfTheIntercepts(Point P1, Point P2, int y)
  1562. {
  1563. int x = (y - P1.Y * P2.X + P1.X * P2.Y) / (P2.Y - P1.Y);
  1564. return x;
  1565. }
  1566. private void ImportSTDDb_Click(object sender, EventArgs e)
  1567. {
  1568. //Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["Sample"])["Members"]);
  1569. string STDName = resultFile.GetSTDName();
  1570. string ResultDbPath = resultFile.GetResultDBPath();
  1571. if (STDName.ToLower().Split('.')[0] == "nostddb")
  1572. {
  1573. OpenFileDialog openFileDialog = new OpenFileDialog();
  1574. openFileDialog.Filter = "(*.db)|*.db";
  1575. openFileDialog.RestoreDirectory = true;
  1576. openFileDialog.FilterIndex = 1;
  1577. openFileDialog.Title = "Please choose a STD to add the rule!";
  1578. if (openFileDialog.ShowDialog() == DialogResult.OK)
  1579. {
  1580. try
  1581. {
  1582. string arguments = openFileDialog.FileName;
  1583. foreach (DisplayParticle item in m_list_allDPart)
  1584. {
  1585. DisplayParticle dp = item;
  1586. if (imageDisHelper.WhetherInRange(dp, m_mouse_now_point))
  1587. {
  1588. arguments += " " + ResultDbPath + " " + dp.FieldId + " " + dp.ParticleId + " " + dp.XRayId;
  1589. break;
  1590. }
  1591. }
  1592. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", arguments);
  1593. p.WaitForExit();
  1594. }
  1595. catch (Exception ex)
  1596. {
  1597. log.Error("OTSPartA_STDEditor:" + ex.ToString());
  1598. }
  1599. }
  1600. }
  1601. else
  1602. {
  1603. string arguments = ".\\Config\\SysData\\" + STDName.Split('.')[0] + ".db";
  1604. foreach (DisplayParticle item in m_list_allDPart)
  1605. {
  1606. DisplayParticle dp = item;
  1607. if (imageDisHelper.WhetherInRange(dp, m_mouse_now_point))
  1608. {
  1609. arguments += " " + ResultDbPath + " " + dp.FieldId + " " + dp.ParticleId + " " + dp.XRayId;
  1610. break;
  1611. }
  1612. }
  1613. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", arguments);
  1614. p.WaitForExit();
  1615. }
  1616. }
  1617. private void 显示国标信息ToolStripMenuItem_Click(object sender, EventArgs e)
  1618. {
  1619. Cursor = Cursors.WaitCursor;
  1620. m_CurGBFields.Clear();
  1621. int index = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  1622. for (int i = 0; i < m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
  1623. {
  1624. string anothername = m_ReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName.ToString();
  1625. string resultfile = m_ReportApp.m_rstDataMgr.ResultFilesList[i].FilePath.ToString() + "\\" + m_ReportApp.m_rstDataMgr.ResultFilesList[i].FileName_real.ToString();
  1626. m_ReportApp.m_rstDataMgr.m_ReportMgr.AddASmplMsrResultMgr(resultfile, anothername);
  1627. }
  1628. OTSCLRINTERFACE.CPropParamClr clr_prop = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetPropertyParamTable();
  1629. List<string> datasourcelist = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  1630. clr_prop.SetDataSourceList(datasourcelist);
  1631. clr_prop.SetDataSourceId(index);//
  1632. clr_prop.SetType((int)DisplayPicutureType.AnalyzeDataTable);//table
  1633. DataTable tbl;//
  1634. var menuItm = (ToolStripMenuItem)sender;
  1635. string tag = menuItm.Tag.ToString();
  1636. switch (tag)
  1637. {
  1638. case "All1":
  1639. clr_prop.SetCalTableType((int)CALCULATE_TABLE_TYPE.GB_Method1);
  1640. tbl = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetAllGBFields(clr_prop);
  1641. break;
  1642. case "DS1":
  1643. clr_prop.SetCalTableType((int)CALCULATE_TABLE_TYPE.GB_Method1);
  1644. tbl = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetGBDSParticles(clr_prop);
  1645. break;
  1646. case "All2":
  1647. clr_prop.SetCalTableType((int)CALCULATE_TABLE_TYPE.GB_Method2);
  1648. tbl = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetAllGBFields(clr_prop);
  1649. break;
  1650. case "DS2":
  1651. clr_prop.SetCalTableType((int)CALCULATE_TABLE_TYPE.GB_Method2);
  1652. tbl = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetGBDSParticles(clr_prop);
  1653. break;
  1654. case "ASTMAll":
  1655. clr_prop.SetCalTableType((int)CALCULATE_TABLE_TYPE.ASTM);
  1656. tbl = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetAllGBFields(clr_prop);
  1657. break;
  1658. default:
  1659. tbl = new DataTable();
  1660. break;
  1661. }
  1662. if (tag == "All1" || tag == "All2" || tag == "ASTMAll")
  1663. {
  1664. if (tbl.Rows.Count > 0)
  1665. {
  1666. foreach (DataRow r in tbl.Rows)
  1667. {
  1668. Point p = new Point(Convert.ToInt32(r["fieldX"]), Convert.ToInt32(r["fieldY"]));
  1669. Point screenP = imageDisHelper.ConvertOTSCoordToScreenCoord(p);
  1670. int gbfldwidth = Convert.ToInt32(710.0 / imageDisHelper.m_pixelSize);
  1671. var df = new DisplayField(gbfldwidth, gbfldwidth, p, screenP);
  1672. df.Zoom(m_zoom_record - 1, new PointF(0, 0));
  1673. df.Move(new SizeF(-m_backRect.X, -m_backRect.Y));
  1674. int topgrade = Convert.ToInt32(r["topGrade"]);
  1675. switch (topgrade)
  1676. {
  1677. case 0:
  1678. df.ContentColor = Color.White;
  1679. break;
  1680. case 1:
  1681. df.ContentColor = Color.DarkGray;
  1682. break;
  1683. case 2:
  1684. df.ContentColor = Color.Purple;
  1685. break;
  1686. case 3:
  1687. df.ContentColor = Color.Blue;
  1688. break;
  1689. case 4:
  1690. df.ContentColor = Color.Red;
  1691. break;
  1692. case 5:
  1693. df.ContentColor = Color.Red;
  1694. break;
  1695. default:
  1696. df.ContentColor = Color.Red;
  1697. break;
  1698. }
  1699. string grade = r["gradeDetail"].ToString();
  1700. df.gradeString = grade;
  1701. m_CurGBFields.Add(df);
  1702. }
  1703. }
  1704. }
  1705. else if (tag == "DS1" || tag == "DS2")
  1706. {
  1707. if (tbl.Rows.Count > 0)
  1708. {
  1709. foreach (DataRow r in tbl.Rows)
  1710. {
  1711. int fid = Convert.ToInt32(r["fieldId"]);
  1712. int pid = Convert.ToInt32(r["particleId"]);
  1713. foreach (var p in m_list_allDPart)
  1714. {
  1715. if (p.objParticleData.FieldId == fid && p.objParticleData.ParticleId == pid)
  1716. {
  1717. p.IsSelect = true;
  1718. break;
  1719. }
  1720. }
  1721. }
  1722. }
  1723. }
  1724. Cursor = Cursors.Default;
  1725. Invalidate();
  1726. }
  1727. private void 清除ToolStripMenuItem_Click(object sender, EventArgs e)
  1728. {
  1729. m_CurGBFields.Clear();
  1730. Invalidate();
  1731. }
  1732. private void ToolStripMenuItem_ParticleSplicing_Click(object sender, EventArgs e)
  1733. {
  1734. SaveFileDialog sfd = new SaveFileDialog();
  1735. sfd.Filter = "png Files(*.png)| *.png |BMP Files(*.bmp)| *.bmp |JPG Files(*.jpg)|*.jpg;*.jpeg";
  1736. if (sfd.ShowDialog() == DialogResult.OK)
  1737. {
  1738. this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
  1739. OutPIC outpic = new OutPIC();
  1740. outpic.m_list_allDfield = m_list_allDfield;
  1741. outpic.resultFile = resultFile;
  1742. outpic.sfd = sfd;
  1743. outpic.type = (int)Outpic_enum.noBackground_pic;
  1744. outpic.m_ReportApp = m_ReportApp;
  1745. Thread bThread = new Thread(new ThreadStart(outpic.opencv_outpic));
  1746. bThread.IsBackground = true;
  1747. bThread.Start();
  1748. }
  1749. }
  1750. protected override bool ProcessDialogKey(Keys keyData)
  1751. {
  1752. if (keyData == Keys.Escape)
  1753. {
  1754. DeselectAllParticle();
  1755. frmReportApp.selectedParticles.Clear();
  1756. return false;
  1757. }
  1758. return base.ProcessDialogKey(keyData);
  1759. }
  1760. private void toolStripMenuItem_Segmentation_Click(object sender, EventArgs e)
  1761. {
  1762. Particle_Segmentation();
  1763. }
  1764. private void toolStripMenuItem_combinClass_Click(object sender, EventArgs e)
  1765. {
  1766. SaveFileDialog sfd = new SaveFileDialog();
  1767. //|ALL Files(*.*)|*.*
  1768. //BMP Files(*.bmp)| *.bmp |
  1769. sfd.Filter = "png Files(*.png)| *.png |BMP Files(*.bmp)| *.bmp |JPG Files(*.jpg)|*.jpg;*.jpeg";
  1770. if (sfd.ShowDialog() == DialogResult.OK)
  1771. {
  1772. OutPIC outpic = new OutPIC();
  1773. outpic.m_list_allDfield = m_list_allDfield;
  1774. outpic.resultFile = resultFile;
  1775. outpic.sfd = sfd;
  1776. outpic.type = (int)Outpic_enum.Render_Combin;
  1777. Thread bThread = new Thread(new ThreadStart(outpic.opencv_outpic2));
  1778. bThread.IsBackground = true;
  1779. bThread.Start();
  1780. }
  1781. }
  1782. private void toolStripMenuItem_combin_Click(object sender, EventArgs e)
  1783. {
  1784. SaveFileDialog sfd = new SaveFileDialog();
  1785. //|ALL Files(*.*)|*.*
  1786. //BMP Files(*.bmp)| *.bmp |
  1787. sfd.Filter = "png Files(*.png)| *.png |BMP Files(*.bmp)| *.bmp |JPG Files(*.jpg)|*.jpg;*.jpeg";
  1788. if (sfd.ShowDialog() == DialogResult.OK)
  1789. {
  1790. OutPIC outpic = new OutPIC();
  1791. outpic.m_list_allDfield = m_list_allDfield;
  1792. outpic.resultFile = resultFile;
  1793. outpic.sfd = sfd;
  1794. outpic.type = (int)Outpic_enum.Combin;
  1795. Thread bThread = new Thread(new ThreadStart(outpic.opencv_outpic2));
  1796. bThread.IsBackground = true;
  1797. bThread.Start();
  1798. }
  1799. }
  1800. private void 显示当前帧国标分类ToolStripMenuItem_Click(object sender, EventArgs e)
  1801. {
  1802. }
  1803. DataTable GetAllPartsOfCurrentGBField()
  1804. {
  1805. DataTable tbl;//
  1806. if (m_CurGBFields.Count == 0)
  1807. {
  1808. return new DataTable();
  1809. }
  1810. int index = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  1811. OTSCLRINTERFACE.CPropParamClr clr_prop = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetPropertyParamTable();
  1812. List<string> datasourcelist = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  1813. clr_prop.SetDataSourceList(datasourcelist);
  1814. clr_prop.SetDataSourceId(index);//
  1815. clr_prop.SetType((int)DisplayPicutureType.AnalyzeDataTable);//table
  1816. DisplayField curfld = new DisplayField(1024,768,new Point(0,0),new Point(0,0));
  1817. foreach (var f in m_CurGBFields)
  1818. {
  1819. if (imageDisHelper.WhetherInRange(f, m_currentMouseDownPoint))
  1820. {
  1821. curfld = f;
  1822. }
  1823. }
  1824. clr_prop.SetCalTableType((int)CALCULATE_TABLE_TYPE.GB_Method1);
  1825. tbl = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetAllParticlesOfOneGBField(clr_prop, curfld.OTSCoordinatePos.X, curfld.OTSCoordinatePos.Y);
  1826. return tbl;
  1827. }
  1828. private void 全部ToolStripMenuItem_Click(object sender, EventArgs e)
  1829. {
  1830. Cursor = Cursors.WaitCursor;
  1831. //m_CurGBFields.Clear();
  1832. var tbl = GetAllPartsOfCurrentGBField();
  1833. if (tbl.Rows.Count > 0)
  1834. {
  1835. foreach (DataRow r in tbl.Rows)
  1836. {
  1837. int fid = Convert.ToInt32(r["fieldId"]);
  1838. int pid = Convert.ToInt32(r["particleId"]);
  1839. foreach (var p in m_list_allDPart)
  1840. {
  1841. if (p.objParticleData.FieldId == fid && p.objParticleData.ParticleId == pid)
  1842. {
  1843. p.IsSelect = true;
  1844. break;
  1845. }
  1846. }
  1847. }
  1848. }
  1849. Cursor = Cursors.Default;
  1850. Invalidate();
  1851. }
  1852. private void aToolStripMenuItem_Click(object sender, EventArgs e)
  1853. {
  1854. Cursor = Cursors.WaitCursor;
  1855. var tbl = GetAllPartsOfCurrentGBField();
  1856. if (tbl.Rows.Count > 0)
  1857. {
  1858. foreach (DataRow r in tbl.Rows)
  1859. {
  1860. int fid = Convert.ToInt32(r["fieldId"]);
  1861. int pid = Convert.ToInt32(r["particleId"]);
  1862. var typestr =Convert.ToString( r["gbClassify"]);
  1863. if (typestr == "A")
  1864. {
  1865. foreach (var p in m_list_allDPart)
  1866. {
  1867. if (p.objParticleData.FieldId == fid && p.objParticleData.ParticleId == pid)
  1868. {
  1869. p.IsSelect = true;
  1870. break;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. }
  1876. Cursor = Cursors.Default;
  1877. Invalidate();
  1878. }
  1879. private void bToolStripMenuItem_Click(object sender, EventArgs e)
  1880. {
  1881. Cursor = Cursors.WaitCursor;
  1882. var tbl = GetAllPartsOfCurrentGBField();
  1883. if (tbl.Rows.Count > 0)
  1884. {
  1885. foreach (DataRow r in tbl.Rows)
  1886. {
  1887. int fid = Convert.ToInt32(r["fieldId"]);
  1888. int pid = Convert.ToInt32(r["particleId"]);
  1889. var typestr = Convert.ToString(r["gbClassify"]);
  1890. if (typestr == "B")
  1891. {
  1892. foreach (var p in m_list_allDPart)
  1893. {
  1894. if (p.objParticleData.FieldId == fid && p.objParticleData.ParticleId == pid)
  1895. {
  1896. p.IsSelect = true;
  1897. break;
  1898. }
  1899. }
  1900. }
  1901. }
  1902. }
  1903. Cursor = Cursors.Default;
  1904. Invalidate();
  1905. }
  1906. private void cToolStripMenuItem_Click(object sender, EventArgs e)
  1907. {
  1908. Cursor = Cursors.WaitCursor;
  1909. var tbl = GetAllPartsOfCurrentGBField();
  1910. if (tbl.Rows.Count > 0)
  1911. {
  1912. foreach (DataRow r in tbl.Rows)
  1913. {
  1914. int fid = Convert.ToInt32(r["fieldId"]);
  1915. int pid = Convert.ToInt32(r["particleId"]);
  1916. var typestr = Convert.ToString(r["gbClassify"]);
  1917. if (typestr == "C")
  1918. {
  1919. foreach (var p in m_list_allDPart)
  1920. {
  1921. if (p.objParticleData.FieldId == fid && p.objParticleData.ParticleId == pid)
  1922. {
  1923. p.IsSelect = true;
  1924. break;
  1925. }
  1926. }
  1927. }
  1928. }
  1929. }
  1930. Cursor = Cursors.Default;
  1931. Invalidate();
  1932. }
  1933. private void dToolStripMenuItem_Click(object sender, EventArgs e)
  1934. {
  1935. Cursor = Cursors.WaitCursor;
  1936. var tbl = GetAllPartsOfCurrentGBField();
  1937. if (tbl.Rows.Count > 0)
  1938. {
  1939. foreach (DataRow r in tbl.Rows)
  1940. {
  1941. int fid = Convert.ToInt32(r["fieldId"]);
  1942. int pid = Convert.ToInt32(r["particleId"]);
  1943. var typestr = Convert.ToString(r["gbClassify"]);
  1944. if (typestr == "D")
  1945. {
  1946. foreach (var p in m_list_allDPart)
  1947. {
  1948. if (p.objParticleData.FieldId == fid && p.objParticleData.ParticleId == pid)
  1949. {
  1950. p.IsSelect = true;
  1951. break;
  1952. }
  1953. }
  1954. }
  1955. }
  1956. }
  1957. Cursor = Cursors.Default;
  1958. Invalidate();
  1959. }
  1960. private DataTable GetGBDataTable(object sender, int met)
  1961. {
  1962. int index = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  1963. for (int i = 0; i < m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
  1964. {
  1965. string anothername = m_ReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName.ToString();
  1966. string resultfile = m_ReportApp.m_rstDataMgr.ResultFilesList[i].FilePath.ToString() + "\\" + m_ReportApp.m_rstDataMgr.ResultFilesList[i].FileName_real.ToString();
  1967. m_ReportApp.m_rstDataMgr.m_ReportMgr.AddASmplMsrResultMgr(resultfile, anothername);
  1968. }
  1969. OTSCLRINTERFACE.CPropParamClr clr_prop = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetPropertyParamTable();
  1970. List<string> datasourcelist = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  1971. clr_prop.SetDataSourceList(datasourcelist);
  1972. clr_prop.SetDataSourceId(index);//
  1973. clr_prop.SetType((int)DisplayPicutureType.AnalyzeDataTable);//table
  1974. DataTable tbl;//
  1975. clr_prop.SetCalTableType(met);
  1976. tbl = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetAllGBFields(clr_prop);
  1977. return tbl;
  1978. }
  1979. private void 方法一ToolStripMenuItem_Click(object sender, EventArgs e)
  1980. {
  1981. SaveFileDialog sfd = new SaveFileDialog();
  1982. sfd.Filter = "png Files(*.png)| *.png |BMP Files(*.bmp)| *.bmp |JPG Files(*.jpg)|*.jpg;*.jpeg";
  1983. if (sfd.ShowDialog() == DialogResult.OK)
  1984. {
  1985. var datd = GetGBDataTable(sender, (int)CALCULATE_TABLE_TYPE.GB_Method1);
  1986. this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
  1987. OutPIC outpic = new OutPIC();
  1988. outpic.GBDatatableOne = datd;
  1989. outpic.GridLength = Convert.ToInt32(710.0 / imageDisHelper.m_pixelSize);
  1990. outpic.m_list_allDfield = m_list_allDfield;
  1991. outpic.resultFile = resultFile;
  1992. outpic.sfd = sfd;
  1993. outpic.type = (int)Outpic_enum.GBOne;
  1994. outpic.m_ReportApp = m_ReportApp;
  1995. Thread bThread = new Thread(new ThreadStart(outpic.opencv_outpic));
  1996. bThread.IsBackground = true;
  1997. bThread.Start();
  1998. }
  1999. }
  2000. private void 方法二ToolStripMenuItem_Click(object sender, EventArgs e)
  2001. {
  2002. SaveFileDialog sfd = new SaveFileDialog();
  2003. sfd.Filter = "png Files(*.png)| *.png |BMP Files(*.bmp)| *.bmp |JPG Files(*.jpg)|*.jpg;*.jpeg";
  2004. if (sfd.ShowDialog() == DialogResult.OK)
  2005. {
  2006. var datd = GetGBDataTable(sender, (int)CALCULATE_TABLE_TYPE.GB_Method2);
  2007. this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
  2008. OutPIC outpic = new OutPIC();
  2009. outpic.GBDatatableOne = datd;
  2010. outpic.GridLength = Convert.ToInt32(710.0 / imageDisHelper.m_pixelSize);
  2011. outpic.m_list_allDfield = m_list_allDfield;
  2012. outpic.resultFile = resultFile;
  2013. outpic.sfd = sfd;
  2014. outpic.type = (int)Outpic_enum.GBOne;
  2015. outpic.m_ReportApp = m_ReportApp;
  2016. Thread bThread = new Thread(new ThreadStart(outpic.opencv_outpic));
  2017. bThread.IsBackground = true;
  2018. bThread.Start();
  2019. }
  2020. }
  2021. private void aSTMToolStripMenuItem1_Click(object sender, EventArgs e)
  2022. {
  2023. SaveFileDialog sfd = new SaveFileDialog();
  2024. sfd.Filter = "png Files(*.png)| *.png |BMP Files(*.bmp)| *.bmp |JPG Files(*.jpg)|*.jpg;*.jpeg";
  2025. if (sfd.ShowDialog() == DialogResult.OK)
  2026. {
  2027. var datd = GetGBDataTable(sender, (int)CALCULATE_TABLE_TYPE.ASTM);
  2028. this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
  2029. OutPIC outpic = new OutPIC();
  2030. outpic.GBDatatableOne = datd;
  2031. outpic.GridLength = Convert.ToInt32(710.0 / imageDisHelper.m_pixelSize);
  2032. outpic.m_list_allDfield = m_list_allDfield;
  2033. outpic.resultFile = resultFile;
  2034. outpic.sfd = sfd;
  2035. outpic.type = (int)Outpic_enum.GBOne;
  2036. outpic.m_ReportApp = m_ReportApp;
  2037. Thread bThread = new Thread(new ThreadStart(outpic.opencv_outpic));
  2038. bThread.IsBackground = true;
  2039. bThread.Start();
  2040. }
  2041. }
  2042. }
  2043. }