1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188 |
- using OTSIncAReportApp.DataOperation.DataAccess;
- using OTSIncAReportApp.DataOperation.Model;
- using OTSIncAReportApp.OTSSampleReportInfo;
- using OTSIncAReportApp.SysMgrTools;
- using OTSIncAReportGraph.Class;
- using OTSIncAReportGraph.OTSIncAReportGraphFuncation;
- using OTSIncAReportMailInterface;
- using OTSPeriodicTable;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Linq;
- using System.Threading;
- using System.Windows.Forms;
- namespace OTSIncAReportGraph.Controls
- {
- public partial class Control_DrawDistrbutionSortImage : UserControl
- {
- //防止segment过多的数量限制,
- private const int m_segment_overflownumber = 400;
- #region 变量定义
- //这里要做成控件,不要是窗体
- public List<BaseObject> m_list_baseobject = null;
- //多边形的分栏,list
- public List<SortParticleDistribution> m_list_sortparticledistribution = null;
- //多边形的分栏list,的原先值,用于缩放拖动等计算使用
- public List<SortParticleDistribution> m_old_list_sortparticledistribution = null;
- //记录操作记录类
- List<HistoryApolygon> m_list_historyapolygon = null;
- //操作历史类,当前操作到的id
- private int m_operator_currentid = 0;
- //背景矩形
- private RectangleF m_backrectf = new RectangleF();
- //记录原值,背景矩形
- private RectangleF m_old_backrectf = new RectangleF();
- //单一Field视域,屏幕像素的宽高
- public RectangleF m_OneField_Screen_BackRectf = new RectangleF();
- //单一Field视域,OTS物理像素的宽高
- public RectangleF m_OneField_OTS_Rectf = new RectangleF();
- //是否使用矩形进行多选操作
- private bool m_is_multiselect_rectangle = false;
- //是否使用圆形进行多选操作
- private bool m_is_multiselect_ellipse = false;
- //是否可以进行绘制,提供给矩形多选与圆形多选使用的临时变量
- private bool m_is_multiselect_onpaint = false;
- //进行选择的矩形范围
- private RectangleF m_multiselect_rect = new RectangleF();
- //在进行拖选前鼠标记录的点
- private PointF m_beforemultiselect_point = new PointF();
- //是否拖动
- private bool m_isDrag = false;
- //拖动前的坐标记录
- private PointF m_beforedrag_pointf = new PointF();
- //记录鼠标拖选完成后形成的路径
- private GraphicsPath m_selectmulti_gpath = new GraphicsPath();
- //缩放的增大缩小的增量
- private float m_f_zoom_increment = 0.1f;
- //缩放的基数,临时变量
- private float m_f_widthandheight_js = 0;
- //与原先缩放的记录数
- public float m_f_zoom_record = 1;
- //最大缩放倍数
- private float m_f_zoom_max = 4f;
- //最小缩放倍数
- private float m_f_zoom_mix = 0.5f;
- //标尺的大小记录
- public float m_f_ruler_size = 100;
- //标尺原先大小的记录,参与计算
- private float m_f_old_ruler_size = 100;
- //每像素代表的尺寸大小,还不知道在哪里进行计算
- public float m_f_onepixel_size = 4.5f;
- //提供鼠标在右下角显示的文本,左侧
- private string m_str_mouseshow_left = "";
- //提供鼠标在右下角显示的文本,右侧
- private string m_str_mouseshow_right = "";
- //分栏网格边框的颜色
- private Color m_c_ColumnRectangleColor = Color.LightSteelBlue;
-
- //底层封装类
- OTSIncAReportFun m_ReportFun = null;
- //鼠标移动经过的颗粒对象,临时存放,用来记录是否要显示xray与隐藏xray
- DParticle m_move_dparticle = null;
- //保存数据源名称
- private string m_showsourcename = "";
- //保存数据源的ID
- private int m_datasourceid = 0;
- //记录当前鼠标位置对应SEM电镜的位置
- Point m_sem_mouse_now_point = new Point();
- //移动SEM到指定位置发生线程
- private Thread m_mythread;
- //记录线程是否已经运行完成的状态
- private bool m_mythread_state = false;
- private bool m_CtrlKeyDown = false;
- /// <summary>
- /// 当前正在显示的数据源名称,用来与框架调用条件判断使用
- /// </summary>
- public string ShowSourceName
- {
- set { m_showsourcename = value; }
- get { return m_showsourcename; }
- }
- /// <summary>
- /// 当前正在显示的数据源ID
- /// </summary>
- public int DataSourceID
- {
- set { m_datasourceid = value; }
- get { return m_datasourceid; }
- }
- /// <summary>
- /// 返回当前缩放的大小因数
- /// </summary>
- public float FZOOMRecord
- {
- get { return m_f_zoom_record; }
- set { m_f_zoom_record = value; }
- }
- //进度条窗体
- public Frm_UserProgress m_frm_userprogress;
- /// <summary>
- /// 是否显示过小颗粒
- /// </summary>
- public bool bShowSmallParticle = false;
- OTSSampleMeaInfo m_list_cgriddataclr = null;
- public OTSIncAReportApp.frmReportApp m_ReportApp;
- //国际化存储信息
- Hashtable table;
- ResultFile resultFile = null;
- #endregion
- #region 构造函数及窗体加载
- /// <summary>
- /// 排序图构造函数
- /// </summary>
- /// <param name="in_sec">传入,委托类对象</param>
- /// <param name="in_Cotsreportprojfilemgrclr">传入,项目管理类对象</param>
- /// <param name="in_cotsreportprojfileclr">传入,项目类对象</param>
- /// <param name="in_csmplmsrresultfilemgrclr">传入,文件管理类对象</param>
- /// <param name="in_csmplmsrresultfileclr">传入,文件类对象</param>
- public Control_DrawDistrbutionSortImage(OTSIncAReportApp.frmReportApp ReportApp)
- {
- m_list_baseobject = new List<BaseObject>();
- m_list_historyapolygon = new List<HistoryApolygon>();
- m_list_sortparticledistribution = new List<SortParticleDistribution>();
- m_old_list_sortparticledistribution = new List<SortParticleDistribution>();
- m_mythread_state = false;
- m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
- m_frm_userprogress = new Frm_UserProgress();
- m_ReportApp = ReportApp;
- resultFile = m_ReportApp.resultFilesList[m_ReportApp.WorkingResult];
- //初始化底层操作类
- m_ReportFun = new OTSIncAReportFun( resultFile);
- InitializeComponent();
- #region 国际化语言
- Language lan = new Language(this);
- table = lan.GetNameTable(this.Name);
- #endregion
- }
- private void Control_DrawDistrbutionSortImage_Load(object sender, EventArgs e)
- {
- //向父窗体注册键盘按键事件
- this.Parent.KeyDown += new KeyEventHandler(Control_DrawDistrbutionSortImage_KeyDown);
- this.Parent.KeyUp += new KeyEventHandler(Control_DrawDistrbutionSortImage_KeyUp);
- control_Ruler1 = new Control_Ruler();
- control_XRayTable1 = new Control_XRayTable();
- //设置鼠标为等待样式
- //m_sec.SendCall("设置鼠标样式", "", "WaitCursor");
- //显示进度条,计算进度条应该显示的位置和宽度
- Form ls_main_form = this.ParentForm.ParentForm;//取出父窗体
- m_frm_userprogress.Width = (int)(MyPrimaryScreen.DESKTOP.Width / MyPrimaryScreen.ScaleX * 0.9);
- m_frm_userprogress.Location = new Point(ls_main_form.Location.X + 80, ls_main_form.Location.Y + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
- m_frm_userprogress.Show();
- m_frm_userprogress.SetProgressValueAndText(0, table["str1"].ToString());
- //调用填充排序图颗粒数据,总过程方法
- GetDistrbutionSortImage_Total();
- //设置双缓冲
- SetDoubleBufferByIsDraw();
- //设置标尺
- //根据f_onepixel_size计算出要显示出100um的实际宽度
- double d_onefixel_width = 100 / m_f_onepixel_size;
- if (d_onefixel_width == 0)
- {
- this.control_Ruler1.Visible = false;
- }
- else
- {
- //将标尺定位到合理的位置上
- this.control_Ruler1.Location = new Point(10, MyPrimaryScreen.WorkingArea.Height - 300);
- this.control_Ruler1.Visible = true;
- this.control_Ruler1.SetValue(m_f_ruler_size, m_f_onepixel_size);
- }
- //加载时将背景rect设置与整个窗体一边大小
- m_backrectf = this.ClientRectangle; //该背景大小并未与实际获得像素的进行关联,这里注意一下,回头观察是否需要改进掉
- m_old_backrectf = m_backrectf;
- //进入时首先对XRayTable进行隐藏
- control_XRayTable1.Visible = false;
- //设置鼠标为默认
- //m_sec.SendCall("设置鼠标样式", "", "Default");
- m_frm_userprogress.SetProgressValueAndText(100, table["str2"].ToString());
- //加载完成,关闭进度条
- m_frm_userprogress.Close();
- }
- /// <summary>
- /// 排序图获取底层数据,组建整张排序图的总方法过程
- /// </summary>
- public void GetDistrbutionSortImage_Total()
- {
- string str48 = "begin to load data....";
- //str48 = table["str48"].ToString();
- m_frm_userprogress.SetProgressValueAndText(1, str48);
- string path = resultFile.FilePath;
- FieldData fieldData = new FieldData(path);
- List<Field> fieldlist = fieldData.GetFieldList();
- //将field的list对象给全局变量中,供后面获取xray使用
- m_ReportFun.m_list_OTSField = fieldlist;
- string str49 = "begin to composit image....";
- //str49 = table["str49"].ToString();
- m_frm_userprogress.SetProgressValueAndText(15, str49);
- //第一次,用来计算,总大小等,获取Field的坐标,id,同时获取对应的ImgClr里的宽高,图像大小
- List<Point> list_point = new List<Point>();
- int i_field_width = 0, i_field_height = 0;
- //获取到该field的分辨率大小,循环中都是一样的
- if (fieldlist.Count > 0)
- {
- Bitmap bitmp = DrawFunction.ReadImageFile(fieldlist[0].FieldImage);
- i_field_width = bitmp.Width;
- i_field_height = bitmp.Height;
- }
- for (int i = 0; i < fieldlist.Count(); i++)
- {
- //然后取出物理坐标,这个一会要与分辨率坐标进行变算一下
- Point ls_point = new Point() { X = fieldlist[i].FieldPosX, Y = fieldlist[i].FieldPosY };
- list_point.Add(ls_point);
- }
- //对单个Field视域的屏幕像素宽高,进行记录
- m_OneField_Screen_BackRectf = new RectangleF(0, 0, i_field_width, i_field_height);
- //获取单个OTS视域像素宽高,并进行记录
- Rectangle OTS_FieldRect = m_ReportFun.GetOneFieldWidthAndHeight(list_point);
- m_OneField_OTS_Rectf = OTS_FieldRect;
- string str50 = "calculate ruler....";
- //str50 = table["str50"].ToString();
- m_frm_userprogress.SetProgressValueAndText(18, str50);
- #region //标尺相关------------------------------------------------------------------------------
- //在此处通过上面的i_field_width,ifield_height和list_point,来计算出个像素与实际物理值的比例
- Rectangle ls_jsblrect = m_ReportFun.GetOneFieldWidthAndHeight(list_point);
- //然后用宽度来除以i_field_width 获取单个的像素比例
- double d_onepixel_scale = Convert.ToDouble(ls_jsblrect.Width) / Convert.ToDouble(i_field_width);
- //再用该比例对标尺进行相应的赋值
- m_f_onepixel_size = (float)d_onepixel_scale;
- #endregion //---------------------------------------------------------------------------------------
- string str51 = "build the whole image....";
- //str51 = table["str51"].ToString();
- m_frm_userprogress.SetProgressValueAndText(20, str51);
- //70的进度条给到下面的循环中
- float ls_int_progresscalc = 0;
- if (fieldlist.Count > 0)
- ls_int_progresscalc = (float)80 / (float)fieldlist.Count;
- string str52 = "Finished";
- //str52 = table["str52"].ToString();
- string str53 = "total";
- //str53 = table["str53"].ToString();
- string str54 = "...";
- //str54 = table["str54"].ToString();
- //第二次,再通过Field取到对应的Particle,循环一次
- for (int i = 0; i < fieldlist.Count(); i++)
- {
- m_frm_userprogress.SetProgressValueAndText(20 + (int)(ls_int_progresscalc * (i + 1)), str52 + i.ToString() + str53 + m_ReportFun.m_list_OTSField.Count.ToString() + str54);
- //先获取该field中的所有particle
- List<Particle> list_cotsparticleclr = new List<Particle>();
- list_cotsparticleclr = fieldlist[i].ParticleList;
- //取出该Field中,从物理坐标转换到像素坐标后.不知道该算法是否可靠,先进行测试判断
- Point offset_point = m_ReportFun.GetFieldPhysicsConvertToScreen(list_point, i_field_width, i_field_height, new Point() { X = fieldlist[i].FieldPosX, Y = fieldlist[i].FieldPosY });
- //然后将取出的数据,转换成Bitmap对象
- Bitmap ls_bt = DrawFunction.ReadImageFile(fieldlist[i].FieldImage);
- //再循环取出所有的particle
- foreach (Particle ls_cotsparticleclr in list_cotsparticleclr)
- {
- List<Feature> list_cotssegmentclr = new List<Feature>();
- list_cotssegmentclr = ls_cotsparticleclr.FeatureList;
- //创建颗粒分布图对应的类对象
- List<DSegment> list_dsegment = new List<DSegment>();
- //定义particle颗粒,并获取该颗粒与标准库中对应的颜色
- DParticle ls_dp = new DParticle();
- ls_dp.CLRFieldID = ls_cotsparticleclr.FieldId; //为我封装的颗粒保存上,底层对应的FieldID
- ls_dp.CLRTagID = ls_cotsparticleclr.ParticleId; //为我封装的颗粒对象保存上,底层对应的TagID
- ls_dp.STDTypeID = ls_cotsparticleclr.TypeId; //为我封装的颗粒对象保存上,类型
- ls_dp.TypeId = ls_cotsparticleclr.TypeId;
- ls_dp.TypeName = ls_cotsparticleclr.TypeName;
- ls_dp.XRayId = ls_cotsparticleclr.XrayId;
- ls_dp.SEMPosX = ls_cotsparticleclr.SEMPosX;
- ls_dp.SEMPosY = ls_cotsparticleclr.SEMPosY;
- ls_dp.Color = m_ReportFun.GetColorBySTDTypeIDForBSEAndSorImage(ls_cotsparticleclr.TypeColor, ls_cotsparticleclr.TypeId);
- //防止segment过多造成程序卡死
- if (list_cotssegmentclr.Count < m_segment_overflownumber)
- //再循环取出里面所有的segment
- foreach (Feature ls_cotssegmentclr in list_cotssegmentclr)
- {
- //这里的坐标未转换
- DSegment ds = new DSegment();
- ds.Rect = new Rectangle(ls_cotssegmentclr.Start + offset_point.X,
- //i_field_height - ls_cotssegmentclr.GetHeight() + offset_point.Y,
- ls_cotssegmentclr.Height + offset_point.Y,
- ls_cotssegmentclr.Length,
- 1);
- //图像上下反了,翻转一下,上下翻转
- //ls_bt.RotateFlip(RotateFlipType.Rotate180FlipX);//使用系统带的图像处理方法,进行x轴的翻转
- //合成图像完成,开始抠取像素---------------------为显示BSE原图而用--------------------------------------------
- int i_ls_length = ls_cotssegmentclr.Length;
- List<Color> ls_list_colors = new List<Color>();
- for (int m = 0; m < i_ls_length; m++)
- {
- //这里实现一下代码保护
- int lsjs_x = ls_cotssegmentclr.Start + m;
- //int lsjs_y = i_field_height - ls_cotssegmentclr.GetHeight();
- int lsjs_y = ls_cotssegmentclr.Height;
- if (lsjs_x < 0)
- lsjs_x = 0;
- if (lsjs_x >= i_field_width)
- lsjs_x = i_field_width - 1;
- if (lsjs_y < 0)
- lsjs_y = 0;
- if (lsjs_y >= i_field_height)
- lsjs_y = i_field_height - 1;
- //按理说这里应该加上个横向抠取像素颜色,这里需要再处理一下
- ls_list_colors.Add(ls_bt.GetPixel(lsjs_x,
- lsjs_y));
- }
- //---------------------------------------------存入标准库相关的信息------------------------------------------------
- ds.Color = ls_dp.Color;//将线的颜色对应到颗粒的颜色
- //------------------------------------------------------------------------------------------------------
- ds.List_Colors = ls_list_colors;
- list_dsegment.Add(ds);
- //ls_bt.Dispose();
- }
- ls_dp.Zoom_DisPlayMultiplier = 0.5f;
- ls_dp.Zoom_DisPlay = true;
- ls_dp.DSegments = list_dsegment; //将segment对应的设置到particle中
- //并对DParticle相关信息进行计算
- ls_dp.Rect = ls_dp.GetRectFromDSegment();
- ls_dp.GPath = ls_dp.GetRegionFromDSegments();
- ls_dp.SmallRect = ls_dp.GetSmallRectangleFromRect();
- //将每个颗粒添加到颗粒分布图中的列表中
- m_list_baseobject.Add(ls_dp);
- }
- }
-
- }
-
-
- /// <summary>
- /// 根据颗粒排序图获取已经选择上的颗粒,返回被选择上的颗粒的列表
- /// </summary>
- /// <returns></returns>
- public List<Particle> GetSelectedParticleList_ForDrawDistrbutionSortImage()
- {
- List<Particle> ls_list_cotsparticleclr = new List<Particle>();
- //防止为空校验判断
- if (m_ReportFun.m_list_OTSField == null)
- {
- return ls_list_cotsparticleclr;
- }
- //先取出,所有被选择的dparticle列表的
- List<DParticle> ls_list_dp = new List<DParticle>();
- foreach (SortParticleDistribution spd in m_list_sortparticledistribution)
- {
- foreach (DParticle ls_dp in spd.List_DParticle)
- {
- if (ls_dp.Operator == ParticleOperator.SELECTED)
- {
- ls_list_dp.Add(ls_dp);
- }
- }
- }
- //并开始查找包含tagid和fieldid的cotsparticle的对象,保存到list当中
- for (int i = 0; i < ls_list_dp.Count(); i++)
- {
- for (int j = 0; j < m_ReportFun.m_list_OTSField.Count(); j++)
- {
- //先获取该field中的所有particle
- List<Particle> list_cotsparticleclr = new List<Particle>();
- list_cotsparticleclr = m_ReportFun.m_list_OTSField[j].ParticleList;
- for (int k = 0; k < list_cotsparticleclr.Count(); k++)
- {
- if (list_cotsparticleclr[k].ParticleId == ls_list_dp[i].CLRTagID
- && list_cotsparticleclr[k].FieldId == ls_list_dp[i].CLRFieldID)
- {
- //将cotsparticleclr保存到list当中
- ls_list_cotsparticleclr.Add(list_cotsparticleclr[k]);
- }
- }
- }
- }
- return ls_list_cotsparticleclr;
- }
- #endregion
- #region 获取数据及初始化数据等
- private void ClassifyDParticleGrid()
- {
- //-------------------这里开始对分布图的颗粒信息,位置大小等重新进行计算-----------------------------------------------------
- //初始化分栏的大小,及多少个分栏。
- //模拟数据,分别将<=1和>1 and <=2和 >2 and <=3的颗粒数据分成三组,进行显示
- SortParticleDistribution sortparticledistribution = new SortParticleDistribution();
- sortparticledistribution.RectF = new RectangleF(this.ClientRectangle.X, this.ClientRectangle.Y, 800, this.ClientRectangle.Height);
- sortparticledistribution.ShowStr = "AAAA的颗粒[尺寸<=1的颗粒]";
- sortparticledistribution.Size_Min = 0;
- sortparticledistribution.Size_Max = 1;
- SortParticleDistribution sortparticledistribution2 = new SortParticleDistribution();
- sortparticledistribution2.RectF = new RectangleF(this.ClientRectangle.X, this.ClientRectangle.Y, 800, this.ClientRectangle.Height);
- sortparticledistribution2.ShowStr = "BBBBB的颗粒[尺寸<2的颗粒]";
- sortparticledistribution2.Size_Min = 0;
- sortparticledistribution2.Size_Max = 1;
- SortParticleDistribution sortparticledistribution3 = new SortParticleDistribution();
- sortparticledistribution3.RectF = new RectangleF(this.ClientRectangle.X, this.ClientRectangle.Y, 800, this.ClientRectangle.Height);
- sortparticledistribution3.ShowStr = "CCCCC的颗粒[尺寸<3的颗粒]";
- sortparticledistribution3.Size_Min = 0;
- sortparticledistribution3.Size_Max = 1;
- //筛选并进行装载
- foreach (DParticle ls_dp in m_list_baseobject)
- {
- if (ls_dp.Zoom_DisPlayMultiplier <= 1f)
- {
- DParticle sort_dp = ls_dp.Clone() as DParticle;
- sort_dp.Rect = sort_dp.GetRectFromDSegment();
- sortparticledistribution.List_DParticle.Add(sort_dp);
- }
- if (ls_dp.Zoom_DisPlayMultiplier > 1f && ls_dp.Zoom_DisPlayMultiplier <= 1.5f)
- {
- DParticle sort_dp = ls_dp.Clone() as DParticle;
- sort_dp.Rect = sort_dp.GetRectFromDSegment();
- sortparticledistribution2.List_DParticle.Add(sort_dp);
- }
- if (ls_dp.Zoom_DisPlayMultiplier > 1.5f && ls_dp.Zoom_DisPlayMultiplier <= 2f)
- {
- DParticle sort_dp = ls_dp.Clone() as DParticle;
- sort_dp.Rect = sort_dp.GetRectFromDSegment();
- sortparticledistribution3.List_DParticle.Add(sort_dp);
- }
- }
- //这里计算每个Grid所在的坐标位置,第二个跟在第一个y轴下面,第三个跟在第二个y轴下面,依此类推
- sortparticledistribution.RectF = new RectangleF(sortparticledistribution.RectF.X,
- sortparticledistribution.RectF.Y,
- sortparticledistribution.RectF.Width,
- sortparticledistribution.GetSortGridHeight());
- sortparticledistribution2.RectF = new RectangleF(sortparticledistribution2.RectF.X,
- sortparticledistribution.RectF.Y + sortparticledistribution.RectF.Height + sortparticledistribution2.RectF.Y - 10,/*-5是为了分栏边框不开缝*/
- sortparticledistribution2.RectF.Width,
- sortparticledistribution2.GetSortGridHeight());
- sortparticledistribution3.RectF = new RectangleF(sortparticledistribution3.RectF.X,
- sortparticledistribution2.RectF.Y + sortparticledistribution2.RectF.Height + sortparticledistribution3.RectF.Y - 10,
- sortparticledistribution3.RectF.Width,
- sortparticledistribution3.GetSortGridHeight());
- m_list_sortparticledistribution.Clear();
- m_old_list_sortparticledistribution.Clear();
- m_list_sortparticledistribution.Add(sortparticledistribution);
- m_list_sortparticledistribution.Add(sortparticledistribution2);
- m_list_sortparticledistribution.Add(sortparticledistribution3);
- //分类完成后,对颗粒重新进行摆放,包括重新计算里面的线,和计算里面多边形的外矩形,+号位置等
- sortparticledistribution.SortDParticle(m_f_zoom_record);
- sortparticledistribution2.SortDParticle(m_f_zoom_record);
- sortparticledistribution3.SortDParticle(m_f_zoom_record);
- //记录原值,从这里继续,clone未完成
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- SortParticleDistribution old_sortparticledistribution = ls_sortparticledistribution.Clone() as SortParticleDistribution;
- m_old_list_sortparticledistribution.Add(old_sortparticledistribution);
- foreach (DParticle ls_dp in old_sortparticledistribution.List_DParticle)
- {
- ls_dp.Rect = ls_dp.GetRectFromDSegment();
- }
- }
- //--------------------------------分类排序颗粒结束-----------------------------------------------------
- }
- /// <summary>
- /// 获取随机的颜色
- /// </summary>
- /// <returns></returns>
- public Color GetRandomColor()
- {
- int R = new Random((int)DateTime.Now.Ticks).Next(255);
- int G = new Random((int)DateTime.Now.Ticks).Next(255);
- int B = new Random((int)DateTime.Now.Ticks).Next(255);
- B = (R + G > 400) ? R + G - 400 : B;//0 : 380 - R - G;
- B = (B > 255) ? 255 : B;
- return Color.FromArgb(R, G, B);
- }
- /// <summary>
- /// 随机获取一个多边形
- /// </summary>
- /// <param name="x"></param>
- /// <param name="y"></param>
- /// <param name="width"></param>
- /// <param name="height"></param>
- /// <returns></returns>
- public DParticle GetRondemDParticle(int x, int y, int width, int height, int r)
- {
- DParticle ls_dp = new DParticle();
- for (int i = 0; i < height; i++)
- {
- DSegment ls_ds = new DSegment();
- ls_ds.Color = GetRandomColor();
- //随机生成x坐标偏移,和宽度
- Random rd = new Random((int)DateTime.Now.Ticks);
- int a = rd.Next(1);
- if (a == 0)
- {
- int n = rd.Next(r);
- x = x + n;
- width = width + n;
- }
- else
- {
- int n = rd.Next(r);
- x = -+n;
- width = width - n;
- }
- ls_ds.Rect = new Rectangle(x, y + i, width, 1);//高度是1的线段
- ls_dp.DSegments.Add(ls_ds);
- }
- return ls_dp;
- }
- #endregion
- #region 设置双缓冲
- /// <summary>
- /// 设置双缓冲
- /// </summary>
- public void SetDoubleBufferByIsDraw()
- {
- SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 双缓冲
- SetStyle(ControlStyles.UserMouse, true);//执行自己的鼠标行为,这个打开后,在win7下鼠标操作明显改善
- }
- #endregion
- #region 绘制函数
- protected override void OnPaint(PaintEventArgs e)//处理重绘情况
- {
- #region //填充个背景色矩形-----------------------------------------------
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- SolidBrush b = new SolidBrush(Color.White);
- e.Graphics.FillRectangle(b, ls_sortparticledistribution.RectF);
- //绘制矩形的外边框
- ControlPaint.DrawBorder(e.Graphics, Rectangle.Round(ls_sortparticledistribution.RectF),
- m_c_ColumnRectangleColor,
- 3,
- ButtonBorderStyle.Solid,
- m_c_ColumnRectangleColor,
- 3,
- ButtonBorderStyle.Solid,
- m_c_ColumnRectangleColor,
- 3,
- ButtonBorderStyle.Solid,
- m_c_ColumnRectangleColor,
- 3,
- ButtonBorderStyle.Solid);
- }
- #endregion
- #region //计算并进行绘制部份------------------------------------
- //绘制完缩放的图形后,将基数变回,否则会一直刷新无限变大变小
- if (m_f_widthandheight_js != 0)
- {
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- //缩放完成,重新计算颗粒的矩形,和边缘路径,这里应该写成,判断 如果有进行了缩放的操作后,再进行重新的计算
- foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
- {
- DParticle dp = (DParticle)item;
- //获取矩形的rectangle
- dp.Rect = dp.GetRectFromDSegment();
- //通过line获取路径边缘
- dp.GPath = dp.GetRegionFromDSegments();
- //重新计算小矩形边框
- dp.SmallRect = dp.GetSmallRectangleFromRect();
- }
- }
- m_f_widthandheight_js = 0;
- }
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- //开始向下传递并进行绘制
- foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
- {
- DParticle dp = (DParticle)item;
- if (dp.Operator != ParticleOperator.DELETED)
- {
- if (dp.Operator == ParticleOperator.DISPLAY)
- {
- item.OnPaint(e);
- }
- }
-
- }
- }
- #endregion
- #region //判断是否使用了矩形或圆形工具进行多选,是的话,那么这里就开始绘制------------------------
- if (true == m_is_multiselect_onpaint)
- {
- if (true == m_is_multiselect_rectangle && m_multiselect_rect.Width > 0 && m_multiselect_rect.Height > 0)
- {
- Graphics g = e.Graphics;
- //绘制矩形
- g.DrawRectangle(new Pen(Color.Blue), m_multiselect_rect.X, m_multiselect_rect.Y, m_multiselect_rect.Width, m_multiselect_rect.Height);
- //半透明画刷
- SolidBrush brush = new SolidBrush(Color.FromArgb(50, Color.SkyBlue));
- //填充选择矩形
- g.FillRectangle(brush, m_multiselect_rect.X, m_multiselect_rect.Y, m_multiselect_rect.Width, m_multiselect_rect.Height);
- }
- if (true == m_is_multiselect_ellipse && m_multiselect_rect.Width > 0 && m_multiselect_rect.Height > 0)
- {
- Graphics g = e.Graphics;
- //绘制圆形
- g.DrawEllipse(new Pen(Color.Blue), m_multiselect_rect.X, m_multiselect_rect.Y, m_multiselect_rect.Width, m_multiselect_rect.Height);
- //半透明画刷
- SolidBrush brush = new SolidBrush(Color.FromArgb(50, Color.SkyBlue));
- //填充选择圆形
- g.FillEllipse(brush, m_multiselect_rect.X, m_multiselect_rect.Y, m_multiselect_rect.Width, m_multiselect_rect.Height);
- }
- }
- #endregion
- #region 分栏Grid的标签文本透明文字实现
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- SolidBrush b = new SolidBrush(Color.White);
- string str_show = ls_sortparticledistribution.ShowStr;
- SizeF sif = e.Graphics.MeasureString(str_show, new Font("宋体", 9));
- e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(125, m_c_ColumnRectangleColor)), ls_sortparticledistribution.RectF.X + ls_sortparticledistribution.RectF.Width - sif.Width - 3, ls_sortparticledistribution.RectF.Y, sif.Width, sif.Height + 3);
- e.Graphics.DrawString(str_show, new Font("宋体", 9), new SolidBrush(Color.Black), ls_sortparticledistribution.RectF.X + ls_sortparticledistribution.RectF.Width - sif.Width - 3, ls_sortparticledistribution.RectF.Y + 3);
- }
- #endregion
- }
- #endregion
- #region 鼠标操作相关事件
- protected override void OnMouseWheel(MouseEventArgs e)
- {
-
- if (m_CtrlKeyDown == true)
- {
- if (e.Delta > 0)
- {
- ZoomIn();
- }
- else
- {
- ZoomOut();
- }
- }
- else
- {
-
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
- {
- DParticle dp = (DParticle)item;
- foreach (DSegment ds in dp.DSegments)
- {
- ds.Rect = new RectangleF(
- ds.Rect.X, //获取到原先点与移动点的增减量,+原先的x坐标,就是新的坐标
- ds.Rect.Y + e.Delta / 2,
- ds.Rect.Width,
- ds.Rect.Height);
-
-
- }
-
- //获取矩形的rectangle
- dp.Rect = dp.GetRectFromDSegment();
-
- if (dp.Rect.Left < -60 || dp.Rect.Right > this.Width +60|| dp.Rect.Top < -60 || dp.Rect.Bottom > this.Height+60)
- {
- dp.Operator = ParticleOperator.NODISPLAY;
- }
- else
- {
- dp.Operator = ParticleOperator.DISPLAY;
- }
- }
- }
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- ls_sortparticledistribution.RectF = new RectangleF(ls_sortparticledistribution.RectF.Location.X,
- ls_sortparticledistribution.RectF.Location.Y + e.Delta / 2, ls_sortparticledistribution.RectF.Width, ls_sortparticledistribution.RectF.Height);
- }
- }
- Invalidate();
- }
- /// <summary>
- /// 放大
- /// </summary>
- private void ZoomIn()
- {
- #region //图形缩放计算部份-------放大------------//是放大
- m_f_widthandheight_js = m_f_zoom_increment;
- for (int x = 0; x < m_list_sortparticledistribution.Count(); x++)
- {
- SortParticleDistribution ls_sortparticledistribution = m_list_sortparticledistribution[x];
- SortParticleDistribution old_ls_sortparticledstribution = m_old_list_sortparticledistribution[x];
- //先计算Grid的背景矩形
- ls_sortparticledistribution.RectF = new RectangleF(ls_sortparticledistribution.RectF.X + old_ls_sortparticledstribution.RectF.X * m_f_zoom_increment,
- ls_sortparticledistribution.RectF.Y + old_ls_sortparticledstribution.RectF.Y * m_f_zoom_increment,
- ls_sortparticledistribution.RectF.Width + Convert.ToInt32(old_ls_sortparticledstribution.RectF.Width * m_f_zoom_increment),
- ls_sortparticledistribution.RectF.Height + Convert.ToInt32(old_ls_sortparticledstribution.RectF.Height * m_f_zoom_increment));
- for (int y = 0; y < ls_sortparticledistribution.List_DParticle.Count(); y++)
- {
- DParticle ls_dp = ls_sortparticledistribution.List_DParticle[y];
- DParticle old_ls_dp = m_old_list_sortparticledistribution[x].List_DParticle[y];
- for (int z = 0; z < ls_dp.DSegments.Count(); z++)
- {
- DSegment ds = ls_dp.DSegments[z];
- DSegment old_ds = old_ls_dp.DSegments[z];
- ds.PenWidthAndHeight = ds.PenWidthAndHeight + old_ds.PenWidthAndHeight
- * m_f_zoom_increment;
- ds.Rect = new RectangleF(ds.Rect.X + old_ds.Rect.X * m_f_zoom_increment, ds.Rect.Y + old_ds.Rect.Y * m_f_zoom_increment,
- ds.Rect.Width + old_ds.Rect.Width * m_f_zoom_increment, ds.Rect.Height + old_ds.Rect.Height * m_f_zoom_increment);
- }
- //设置缩放到多少倍时进行显示
- if (ls_dp.Zoom_DisPlayMultiplier <= m_f_zoom_record)
- {
- ls_dp.Zoom_DisPlay = true;
- }
- else
- {
- ls_dp.Zoom_DisPlay = false;
- }
- }
- }
- m_f_zoom_record = m_f_zoom_record + m_f_zoom_increment;
- m_f_zoom_record = float.Parse(m_f_zoom_record.ToString("#0.0")); //四舍五入,保留一位小数,如果不这样,float会不附合规则
- #endregion
- #region 计算标尺尺寸部份-----放大------
- m_f_ruler_size = m_f_ruler_size + Convert.ToInt32(m_f_old_ruler_size * m_f_zoom_increment);
- control_Ruler1.SetValue(m_f_ruler_size, m_f_onepixel_size);
- #endregion
- }
- /// <summary>
- /// 缩小
- /// </summary>
- private void ZoomOut()
- {
- #region //图形缩放计算部份------缩小--------------------
- m_f_widthandheight_js = -m_f_zoom_increment;
- for (int x = 0; x < m_list_sortparticledistribution.Count(); x++)
- {
- SortParticleDistribution ls_sortparticledistribution = m_list_sortparticledistribution[x];
- SortParticleDistribution old_ls_sortparticledistribution = m_old_list_sortparticledistribution[x];
- //先计算Grid的背景矩形
- ls_sortparticledistribution.RectF = new RectangleF(ls_sortparticledistribution.RectF.X + old_ls_sortparticledistribution.RectF.X * -m_f_zoom_increment,
- ls_sortparticledistribution.RectF.Y + old_ls_sortparticledistribution.RectF.Y * -m_f_zoom_increment,
- ls_sortparticledistribution.RectF.Width + Convert.ToInt32(old_ls_sortparticledistribution.RectF.Width * -m_f_zoom_increment),
- ls_sortparticledistribution.RectF.Height + Convert.ToInt32(old_ls_sortparticledistribution.RectF.Height * -m_f_zoom_increment));
- for (int y = 0; y < ls_sortparticledistribution.List_DParticle.Count(); y++)
- {
- DParticle ls_dp = ls_sortparticledistribution.List_DParticle[y];
- DParticle old_ls_dp = m_old_list_sortparticledistribution[x].List_DParticle[y];
- for (int z = 0; z < ls_dp.DSegments.Count(); z++)
- {
- DSegment ds = ls_dp.DSegments[z];
- DSegment old_ds = old_ls_dp.DSegments[z];
- ds.PenWidthAndHeight = ds.PenWidthAndHeight + old_ds.PenWidthAndHeight
- * -m_f_zoom_increment;
- ds.Rect = new RectangleF(ds.Rect.X + old_ds.Rect.X * -m_f_zoom_increment, ds.Rect.Y + old_ds.Rect.Y * -m_f_zoom_increment,
- ds.Rect.Width + old_ds.Rect.Width * -m_f_zoom_increment, ds.Rect.Height + old_ds.Rect.Height * -m_f_zoom_increment);
- }
- //设置缩放到多少倍时进行显示
- if (ls_dp.Zoom_DisPlayMultiplier <= m_f_zoom_record)
- {
- ls_dp.Zoom_DisPlay = true;
- }
- else
- {
- ls_dp.Zoom_DisPlay = false;
- }
- }
- }
- m_f_zoom_record = m_f_zoom_record - m_f_zoom_increment;
- m_f_zoom_record = float.Parse(m_f_zoom_record.ToString("#0.0")); //四舍五入,保留一位小数,如果不这样,float会不附合规则
- #endregion
- #region 计算标尺尺寸部份-----缩小------f_onepixel_size,是不是该乘以rulerwidth是实际的长度
- m_f_ruler_size = m_f_ruler_size + Convert.ToInt32(m_f_old_ruler_size * -m_f_zoom_increment);
- control_Ruler1.SetValue(m_f_ruler_size, m_f_onepixel_size);
- #endregion
- }
- private void Control_DrawDistrbutionSortImage_KeyDown(object sender, KeyEventArgs e)
- {
- //判断是否按下了ctrl键
- if (e.KeyCode == Keys.ControlKey)
- {
- m_CtrlKeyDown = true;
- }
- }
- private void Control_DrawDistrbutionSortImage_KeyUp(object sender, KeyEventArgs e)
- {
- //判断是否按下了ctrl键
- if (e.KeyCode == Keys.ControlKey)
- {
- m_CtrlKeyDown = false;
- }
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- this.Cursor = Cursors.Hand;
- //是否可以按矩形进行选取,如果选择了矩形或圆形多选后
- if (true == m_is_multiselect_rectangle || true == m_is_multiselect_ellipse)
- {
- m_multiselect_rect.Width = 0;
- m_multiselect_rect.Height = 0;
- m_is_multiselect_onpaint = true;
- m_beforemultiselect_point = e.Location;
- }
- //在进行多选时,不让其拖动
- if (false == m_is_multiselect_onpaint)
- {
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- foreach (DParticle ls_dp in ls_sortparticledistribution.List_DParticle)
- {
- ls_dp.IsDragging = true;
- ls_dp.DraggingPoint = e.Location;
- }
- }
- }
- m_isDrag = true;
- m_beforedrag_pointf = e.Location;
- }
- Invalidate();
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- this.Cursor = Cursors.Default;
- //还原多选变量
- if (true == m_is_multiselect_onpaint)
- {
- //首先清除掉所有已经选择的项
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- foreach (DParticle dp in ls_sortparticledistribution.List_DParticle)
- {
- if (dp.Operator == ParticleOperator.SELECTED)
- {
- dp.Operator = ParticleOperator.DISPLAY;
- }
- }
- }
- //然后在这里判断都有哪些颗粒所有的point点,是否在选取的图形graphicsPath闭合路径中
- //首先先将选取的图形填充成graphicsPath
- if (m_multiselect_rect.Width > 0 && m_multiselect_rect.Height > 0)
- {
- GraphicsPath ls_gpath = new GraphicsPath();
- ls_gpath.AddRectangle(m_multiselect_rect);
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- foreach (DParticle dp in ls_sortparticledistribution.List_DParticle)
- {
- if (dp.Operator != ParticleOperator.NODISPLAY && dp.Operator != ParticleOperator.DELETED)//不显示的和删除状态的不让进行选择
- {
- PointF[] lspointf = dp.GPath.PathPoints;
- for (int i = 0; i < lspointf.Count(); i++)
- {
- if (true == m_ReportFun.WhetherInRange(dp, lspointf[i]))
- {
- //选择到了该路径,那么就选取该图像
- dp.Operator = ParticleOperator.SELECTED;
- }
- }
- }
- }
- }
- }
- //这里恢复默认值
- m_multiselect_rect.Width = 0;
- m_multiselect_rect.Height = 0;
- m_is_multiselect_onpaint = false;
- m_is_multiselect_ellipse = false;
- m_is_multiselect_rectangle = false;
- //将排列图选择的颗粒传送给报告框架中
- SelectParticleListSendToReportFrame();
- }
- //在进行多选时,不让其拖动
- if (false == m_is_multiselect_onpaint)
- {
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
- {
- if (true == item.IsDragging)
- {
- item.IsSelect = false;
- item.IsDragging = false;
- item.DraggingPoint = Point.Empty;
- }
- }
- }
- m_isDrag = false;
- //在颗粒上点击,则对该颗粒附加显示x-ray的状态,同时将其它颗粒上显示x-ray的状态全部去掉。
- if (false == m_isDrag)
- {
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- foreach (DParticle dp in ls_sortparticledistribution.List_DParticle)
- {
- PointF[] lspointf = dp.GPath.PathPoints;
- if (true ==m_ReportFun. WhetherInRange(dp, new Point(e.X, e.Y)))
- {
- //选择到了该路径,那么就选取该图像b
- dp.Operator_ShowXRay = ParticleOperatorShowXray.SELECTANDDISPLAYXRAY;
- }
- else
- {
- dp.Operator_ShowXRay = ParticleOperatorShowXray.NODISPLAY;
- }
- }
- }
- }
- }
- }
- //右键菜单控件
- CMenuStrip.Items[0].Tag = "";
- CMenuStrip.Items[0].Enabled = false;
- CMenuStrip.Items[1].Tag = "";
- CMenuStrip.Items[1].Enabled = false;
- CMenuStrip.Items[2].Tag = "";
- CMenuStrip.Items[2].Enabled = false;
- CMenuStrip.Items[3].Tag = "";
- CMenuStrip.Items[3].Enabled = false;
- CMenuStrip.Items[4].Tag = "";
- CMenuStrip.Items[4].Enabled = false;
- if (e.Button == MouseButtons.Right)
- {
- //这个判断右键菜单加在这里,也不知道对不对
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
- {
- if (true == m_ReportFun.WhetherInRange((DParticle)item, e.Location))
- {
- DParticle dp = (DParticle)item;
- if (dp.Operator == ParticleOperator.DISPLAY || dp.Operator == ParticleOperator.SELECTED)
- {
- CMenuStrip.Items[0].Enabled = true;
- CMenuStrip.Items[0].Tag = dp;
- CMenuStrip.Items[1].Enabled = true;
- if (dp.Operator == ParticleOperator.SELECTED)
- {
- CMenuStrip.Items[1].Text = "取消颗粒选择";
- }
- else
- {
- CMenuStrip.Items[1].Text = "选择颗粒";
- }
- CMenuStrip.Items[2].Enabled = true;
- CMenuStrip.Items[3].Enabled = true;
- //线程未执行完成,则不让再进行选择,右键移动到SEM位置的菜单选项
- if (m_mythread_state == false)
- CMenuStrip.Items[4].Enabled = true;
- else
- CMenuStrip.Items[4].Enabled = false;
- m_sem_mouse_now_point = new Point(dp.SEMPosX, dp.SEMPosY);
- m_str_mouseshow_left = "颗粒SEM位置:" + dp.SEMPosX.ToString() + ":" + dp.SEMPosY.ToString();
- //获取颜色方法1,使用API来获取当前鼠标指向位置的颜色值-------------------------------------------
- Graphics g = Graphics.FromHwnd(this.Handle);
- IntPtr hdc = g.GetHdc();
- uint u_color = 0;
- try
- {
- u_color = DrawFunction.GetPixel(hdc, e.X, e.Y);
- }
- catch
- { }
- Color ls_c = Color.FromArgb
- (
- (int)(u_color << 24 >> 24),
- (int)(u_color << 16 >> 24),
- (int)(u_color << 8 >> 24)
- );
- m_str_mouseshow_right = "灰度#" + ls_c.R.ToString();
- // 这里发送消息
- m_ReportApp.mouseMatter.Text = m_str_mouseshow_right;
- m_ReportApp.RSGrayVal.Text = m_str_mouseshow_left;
- }
- }
- }
- }
- }
- //Invalidate();
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- //如果是进行多选的话
- if (true == m_is_multiselect_onpaint)
- {
- if (e.Location.X > m_beforemultiselect_point.X && e.Location.Y > m_beforemultiselect_point.Y)
- {
- //右下拖动
- m_multiselect_rect = new RectangleF(m_beforemultiselect_point, new SizeF(e.Location.X - m_beforemultiselect_point.X, e.Location.Y - m_beforemultiselect_point.Y));
- }
- if (e.Location.X < m_beforemultiselect_point.X && e.Location.Y < m_beforemultiselect_point.Y)
- {
- //左上拖动
- PointF lspointf = new PointF(e.Location.X, e.Location.Y);
- m_multiselect_rect = new RectangleF(lspointf, new SizeF(m_beforemultiselect_point.X - e.Location.X, m_beforemultiselect_point.Y - e.Location.Y));
- }
- if (e.Location.X > m_beforemultiselect_point.X && e.Location.Y < m_beforemultiselect_point.Y)
- {
- //右上,这种画法,需要将左下,右上两点转换成左上,右下
- PointF left_pointf = new PointF(m_beforemultiselect_point.X, e.Location.Y);
- PointF right_pointf = new PointF(e.Location.X, m_beforemultiselect_point.Y);
- m_multiselect_rect = new RectangleF(left_pointf, new SizeF(right_pointf.X - left_pointf.X, right_pointf.Y - left_pointf.Y));
- }
- if (e.Location.X < m_beforemultiselect_point.X && e.Location.Y > m_beforemultiselect_point.Y)
- {
- //左下,这种画法,需要将左下,右上两点转换成左上,右下
- PointF left_pointf = new PointF(e.Location.X, m_beforemultiselect_point.Y);
- PointF right_pointf = new PointF(m_beforemultiselect_point.X, e.Location.Y);
- m_multiselect_rect = new RectangleF(left_pointf, new SizeF(right_pointf.X - left_pointf.X, right_pointf.Y - left_pointf.Y));
- }
- }
- //判断没有在进行多选状态时,在进行多选时,不让其拖动
- if (false == m_is_multiselect_onpaint)
- {
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
- {
- DParticle dp = (DParticle)item;
- //在计算前,先重新对颗粒的边缘进行计算,防止错误
- dp.GPath = dp.GetRegionFromDSegments();
- if (true == m_ReportFun.WhetherInRange(dp, e.Location))
- {
- if (dp.Operator == ParticleOperator.DISPLAY)
- {
- dp.IsMouseMove = true;
- //显示xray图
- if (control_XRayTable1.Visible == false)
- ShowXRay(dp);
- }
- }
- else
- {
- dp.IsMouseMove = false;
- //移动在颗粒外面时,要判断,Operator_ShowXray不为选下显示XRAY时,才对XRay进行隐藏
- if (dp.Operator_ShowXRay != ParticleOperatorShowXray.SELECTANDDISPLAYXRAY)
- {
- //隐藏x-ray能谱图
- HideXRay(dp);
- }
- }
- if (true == item.IsDragging)
- {
- //再将里面的线也进行计算坐标
- foreach (DSegment ds in dp.DSegments)
- {
- ds.Rect = new RectangleF(
- ds.Rect.X + e.X - item.DraggingPoint.X, //获取到原先点与移动点的增减量,+原先的x坐标,就是新的坐标
- ds.Rect.Y + e.Y - item.DraggingPoint.Y,
- ds.Rect.Width,
- ds.Rect.Height);
- ds.DraggingPoint = e.Location;
- }
- item.DraggingPoint = e.Location;
- //获取矩形的rectangle
- dp.Rect = dp.GetRectFromDSegment();
- //通过line获取路径边缘
- dp.GPath = dp.GetRegionFromDSegments();
- //重新计算小矩形边框
- dp.SmallRect = dp.GetSmallRectangleFromRect();
- if (dp.Rect.Left < 0 || dp.Rect.Right > this.Width || dp.Rect.Top < 0 || dp.Rect.Bottom > this.Height)
- {
- dp.Operator = ParticleOperator.NODISPLAY;
- }
- }
- }
- }
- //如果在拖动中
- if (true == m_isDrag)
- {
- //同样重新计算backrectf的坐标
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- ls_sortparticledistribution.RectF = new RectangleF(ls_sortparticledistribution.RectF.Location.X + e.X - m_beforedrag_pointf.X,
- ls_sortparticledistribution.RectF.Location.Y + e.Y - m_beforedrag_pointf.Y, ls_sortparticledistribution.RectF.Width, ls_sortparticledistribution.RectF.Height);
- }
- m_beforedrag_pointf = e.Location;
- }
- }
- #region 向报告程序右下角,传送鼠标颗粒等相关信息
- //然后这里还要将鼠标移动经过的过程,传输给reportapp中,为了能让reportapp能显示出来
- //如果前面鼠标没有移动到颗粒的位置上,str_mouseshow_left=="",所以再取显示鼠标的位置信息
- m_str_mouseshow_left = "无";
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- foreach (BaseObject item in ls_sortparticledistribution.List_DParticle)
- {
- DParticle dp = (DParticle)item;
- if (true == m_ReportFun.WhetherInRange(dp, e.Location))
- {
- if (dp.Operator == ParticleOperator.DISPLAY)
- {
-
- m_sem_mouse_now_point = new Point(dp.SEMPosX, dp.SEMPosY);
- m_str_mouseshow_left = "颗粒SEM位置:" + dp.SEMPosX.ToString() + ":" + dp.SEMPosY.ToString();
- }
- }
- }
- }
- //获取颜色方法1,使用API来获取当前鼠标指向位置的颜色值-------------------------------------------
- Graphics g = Graphics.FromHwnd(this.Handle);
- IntPtr hdc = g.GetHdc();
- uint u_color = 0;
- try
- {
- u_color = DrawFunction.GetPixel(hdc, e.X, e.Y);
- }
- catch
- { }
- Color ls_c = Color.FromArgb
- (
- (int)(u_color << 24 >> 24),
- (int)(u_color << 16 >> 24),
- (int)(u_color << 8 >> 24)
- );
- m_str_mouseshow_right = "灰度#" + ls_c.R.ToString();
- // 这里发送消息
- m_ReportApp.mouseMatter.Text = m_str_mouseshow_right;
- m_ReportApp.RSGrayVal.Text = m_str_mouseshow_left;
- #endregion
- Invalidate();
- }
- #endregion
- #region 自定义功能函数
- /// <summary>
- /// 复制图像
- /// </summary>
- private void CopyImage()
- {
- int height, width;
- width = this.Width;
- height = this.Height;
- Bitmap image = new Bitmap(width, height);
- this.DrawToBitmap(image, new Rectangle(0, 0, width, height));
- Clipboard.SetImage(image);
- }
- /// <summary>
- /// 移动SEM到指定位置线程函数
- /// </summary>
- private void Thread_GO(object in_obj)
- {
- if (m_mythread_state == false)
- {
- m_mythread_state = true;
- Point sem_point = (Point)in_obj;
- //第一步,连接电镜
- m_ReportFun.ConnectToSEM();
- Thread.Sleep(500);
- //第二步,移动到指定位置,先读取再设置
- if (m_ReportFun.m_SEMConnectionState == true)
- {
- m_ReportFun.MoveSemToPointXY(sem_point.X, sem_point.Y);
- }
- Thread.Sleep(1500);
- //第三步,断开电镜连接
- m_ReportFun.DisConnectSEM();
- //Thread.Sleep(1000);
- m_mythread_state = false;
- }
- }
- /// <summary>
- /// 显示x-ray能谱图
- /// </summary>
- /// <param name="in_dparticle"></param>
- private void ShowXRay(DParticle in_dparticle)
- {
- //显示xray相关信息
- uint[] Search_xray = new uint[2000];
- uint[] Analysis_xray = new uint[2000];
- //
- int i_xray_id = 0;
- List<Element> list_celementchemistryclr = new List<Element>();
- //获取Xray数据
- m_ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(in_dparticle.CLRTagID, in_dparticle.CLRFieldID, out Search_xray, out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
- //get CElementChemistryClr list
- List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
- for (int i = 0; i < list_celementchemistryclr.Count; i++)
- {
- ShowElementInfo ls_sei = new ShowElementInfo();
- ls_sei.ElementName = list_celementchemistryclr[i].Name;
- ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
- ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByYsm(CListPeriodic.GetListPeriodic(), ls_sei.ElementName).SX1);
- list_showelementinfo.Add(ls_sei);
- }
- //获取使用标准库的名称,也许这个也不是很正确??
- string str_stdname = "";
- string str_IncALibName = "";
- //List<int> FLID = new List<int>() { 0, 1, 2, 4, 6, 9 };
- //List<string> NameList = new List<string>() { "过小颗粒", "过大颗粒", "亮度不在分析范围内的颗粒", "低计数率颗粒", "不含分析元素的颗粒", "未识别颗粒" };
- //if (in_dparticle.STDTypeID < 1000)
- //{
- // int index = FLID.IndexOf(in_dparticle.TypeId);
- // if (index == -1)
- // {
- // index = 5;
- // }
- // //小于1000,使用系统默认分类
- // str_IncALibName = NameList[index];
- // str_stdname = "默认标准库";
- //}
- //else if (in_dparticle.STDTypeID >= 1000 && in_dparticle.STDTypeID < 10000)
- //{
- // //大于等于1000,并且小于10000时,使用系统数据库中夹杂物来分析
- // str_IncALibName = in_dparticle.TypeName;
- // str_stdname = "用户定义标准库";
- //}
- //else if (in_dparticle.STDTypeID > 10000)
- //{
- // //大于10000时,使用用户标准库来分析夹杂物名称
- // str_IncALibName = in_dparticle.TypeName;
- // if (str_stdname == "")
- // str_stdname = "系统标准库";
- //}
- //获取数据后,需要对xraytable设置
- control_XRayTable1.Visible = false;
- control_XRayTable1.SetXRayShowLineValue(Search_xray, Analysis_xray, list_showelementinfo);
- //control_XRayTable1.GoodName = str_IncALibName + "(" + in_dparticle.STDTypeID.ToString() + ")";//杂夹物
- control_XRayTable1.GoodName = str_IncALibName;//杂夹物
- control_XRayTable1.STDName = str_stdname;//标准库
- control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
- control_XRayTable1.Visible = true;
- //将显示xray的dparticle记录给全局变量
- m_move_dparticle = in_dparticle;
- this.Refresh();
- }
- /// <summary>
- /// 隐藏x-ray能谱图
- /// </summary>
- private void HideXRay(DParticle in_dparticle)
- {
- if (m_move_dparticle == null)
- return;
- else if (m_move_dparticle.ID == in_dparticle.ID)
- {
- //如果是刚才移动过的颗粒的话,那么这里再对xray进行隐藏
- control_XRayTable1.Visible = false;
- }
- }
- /// <summary>
- /// 封装,将排列图中的颗粒list传送给报告项目框架中
- /// </summary>
- private void SelectParticleListSendToReportFrame()
- {
- //先获取排列图中,有哪些颗粒已经被选择上了
- m_ReportApp.SelectedParticles = GetSelectedParticleList_ForDrawDistrbutionSortImage();
- }
- /// <summary>
- /// 设置当前对哪些颗粒进行设置为选择状态
- /// </summary>
- /// <param name="in_list_cotsparticleclr"></param>
- public void SetSelectParticle(List<Particle> in_list_cotsparticleclr)
- {
- if (in_list_cotsparticleclr == null)
- {
- return;
- }
- if (in_list_cotsparticleclr.Count == 0)
- {
- return;
- }
- foreach (SortParticleDistribution spd in m_list_sortparticledistribution)
- {
- foreach (DParticle ls_dp in spd.List_DParticle)
- {
- //只有显示状态,才可以切换到选择状态,考虑可能会出现如果在条件选择成不显示状态下,如果被选择了,是不是就强制切换成了选择状态
- if (ls_dp.Operator == ParticleOperator.DISPLAY)
- {
- for (int i = 0; i < in_list_cotsparticleclr.Count; i++)
- {
- if (in_list_cotsparticleclr[i].ParticleId == ls_dp.CLRTagID
- && in_list_cotsparticleclr[i].FieldId == ls_dp.CLRFieldID)
- {
- ls_dp.Operator = ParticleOperator.SELECTED;
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 按框架传入的底层计算结果,重新对颗粒进行区分显示
- /// </summary>
- /// <param name="in_cgriddataclr"></param>
- public void Control_DrawDistrbutionSortImage_ByQuery(OTSIncAReportApp.OTSSampleReportInfo.OTSSampleMeaInfo in_list_cgriddataclr)
- {
- m_list_cgriddataclr = in_list_cgriddataclr;
- GetDistrbutionSortimage_ByQuery(in_list_cgriddataclr);
- }
- /// <summary>
- /// 颗粒排序图中的颗粒,重新组织显示颗粒排序规则
- /// </summary>
- public void GetDistrbutionSortimage_ByQuery(OTSIncAReportApp.OTSSampleReportInfo.OTSSampleMeaInfo sourceGridData)
- {
- List<string> FLNameList = new List<string>();
- //List<int> FLID = new List<int>() { -1,0, 1, 2, 4, 6, 7, 8, 9 };
- List<int> FLID = new List<int>() { 0, 1, 2, 4, 6, 9, 10 };
- List<string> NameList = new List<string>();
- int fltype = 0;
- //先清除list
- m_list_sortparticledistribution.Clear();
- m_old_list_sortparticledistribution.Clear();
- m_f_zoom_record = 1;
- //------------------------------------分解结果内容部份------------------------------------
- string display_type = "";
- string con = "";
- var list = sourceGridData.SampleDataList.Find(s => Convert.ToInt32(s.iItemId) == 4);
- string sort_type = list.itemVal.ToString();
- int _type = list.comboDownList.IndexOf(sort_type);
- switch (_type)
- {
- case 0:
- fltype = 0;
- break;
- case 1:
- fltype = 1;
- break;
- case 2:
- fltype = 2;
- display_type = sourceGridData.SampleDataList.Find(s => Convert.ToInt32(s.iItemId) == 13).itemVal.ToString();
- switch (display_type)
- {
- case "DMAX":
- con = "DMAX";
- break;
- case "DMIN":
- con = "DMIN";
- break;
- case "Area":
- con = "Area";
- break;
- case "FERET":
- con = "DFERET";
- break;
- }
- break;
- }
- string path = resultFile.FilePath;
- ParticleData particleData = new ParticleData(path);
- List<Particle> particles = particleData.GetParticleListByCon("", "", "", 0);
- foreach (DParticle ls_dp in m_list_baseobject)
- {
- int dis = 0;
- foreach (Particle particle in particles)
- {
- //找到对应的颗粒,将分类设置进去
- if (ls_dp.CLRTagID == particle.ParticleId && ls_dp.CLRFieldID == particle.FieldId)
- {
- if (!FLNameList.Contains(particle.TypeName) && particle.TypeName != "")
- {
- FLNameList.Add(particle.TypeName);
- }
- if (fltype == 0)
- {
- ls_dp.ParticleFL = particle.TypeId.ToString();
- }
- if (fltype == 1)
- {
- ls_dp.ParticleFL = particle.TypeName.ToString();
- }
- if (fltype == 2)
- {
- if (con == "DMAX")
- ls_dp.ParticleFL = particle.DMAX.ToString();
- if (con == "DMIN")
- ls_dp.ParticleFL = particle.DMIN.ToString();
- if (con == "Area")
- ls_dp.ParticleFL = particle.Area.ToString();
- if (con == "DFERET")
- ls_dp.ParticleFL = particle.FERET.ToString();
- }
- ls_dp.Operator = ParticleOperator.DISPLAY;
- dis = 1;
- break;
- }
- }
- if (dis == 0)
- {
- ls_dp.Operator = ParticleOperator.NODISPLAY;
- }
- }
- if (fltype == 0)
- {
- //NameList = new List<string>() { table["partcletype0"].ToString(), table["partcletype1"].ToString(), table["partcletype2"].ToString(), table["partcletype4"].ToString(), table["partcletype6"].ToString(), table["partcletype7"].ToString(), table["partcletype8"].ToString(), table["partcletype9"].ToString(), table["partcletype10"].ToString() };
- NameList = new List<string>() { table["partcletype9"].ToString(), table["partcletype10"].ToString() };
- }
- if (fltype == 1)
- {
- NameList = FLNameList;
- }
- if (fltype == 2)
- {
- //获取粒级表
- string flpath = m_ReportApp.m_RptConfigFile.FileFolderSize + m_ReportApp.m_RptConfigFile.PartSizeFile;
- DataSet ds = XMLoperate.GetXml(flpath);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- List<string> sizeList = new List<string>();
- for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
- {
- if (sizestr.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
- double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
- sizeList.Add(d1.ToString() + "~" + d2.ToString());
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- sizeList.Add(d.ToString() + "~MAX");
- NameList = sizeList;
- }
- //为颗粒排序图,创建分栏grid
- foreach (string name in NameList)
- {
- SortParticleDistribution sortparticledistribution = new SortParticleDistribution();
- sortparticledistribution.RectF = new RectangleF(ClientRectangle.X, ClientRectangle.Y,
- 800, ClientRectangle.Height);
- sortparticledistribution.ShowStr = name;//设置分类grid
- m_list_sortparticledistribution.Add(sortparticledistribution);
- }
- //然后再重新将list_baseobject中的颗粒,分别添加到对应的sortgrid中
- foreach (DParticle ls_dp in m_list_baseobject)
- {
- var sort = m_list_sortparticledistribution;
- for (int i = 0; i < sort.Count; i++)
- {
- if (fltype == 0)
- {
- if (ls_dp.STDTypeID == FLID[i])
- {
- //将对应的颗粒添加到分栏grid中
- DParticle sort_dp = ls_dp.Clone() as DParticle;
- sort_dp.Rect = sort_dp.GetRectFromDSegment();
- sort[i].List_DParticle.Add(sort_dp);
- break;
- }
- else if (ls_dp.STDTypeID > 10000)
- {
- //将对应的颗粒添加到分栏grid中
- DParticle sort_dp = ls_dp.Clone() as DParticle;
- sort_dp.Rect = sort_dp.GetRectFromDSegment();
- sort[sort.Count - 1].List_DParticle.Add(sort_dp);
- break;
- }
- }
- else if (fltype == 1)
- {
- if (ls_dp.TypeName == NameList[i])
- {
- //将对应的颗粒添加到分栏grid中
- DParticle sort_dp = ls_dp.Clone() as DParticle;
- sort_dp.Rect = sort_dp.GetRectFromDSegment();
- sort[i].List_DParticle.Add(sort_dp);
- break;
- }
- }
- else if (fltype == 2)
- {
- double min = Convert.ToDouble(NameList[i].Split('~')[0]);
- double max = 0;
- if (NameList[i].Split('~')[1].ToLower() != "max")
- { max = Convert.ToDouble(NameList[i].Split('~')[1]); }
- else
- {
- max = 999;
- }
- double size = Convert.ToDouble(ls_dp.ParticleFL);
- if (size <= max && size >= min)
- {
- //将对应的颗粒添加到分栏grid中
- DParticle sort_dp = ls_dp.Clone() as DParticle;
- sort_dp.Rect = sort_dp.GetRectFromDSegment();
- sort[i].List_DParticle.Add(sort_dp);
- break;
- }
- }
- }
- }
- //循环分栏grid,对各分栏grid进行摆放
- for (int i = 0; i < m_list_sortparticledistribution.Count(); i++)
- {
- //计算y轴,的增量
- float ls_height = 0;
- if (i == 0)
- {
- ls_height = 0;
- }
- else
- {
- ls_height = m_list_sortparticledistribution[i - 1].RectF.Y +
- m_list_sortparticledistribution[i - 1].RectF.Height - 10;
- }
- m_list_sortparticledistribution[i].RectF = new RectangleF(
- m_list_sortparticledistribution[i].RectF.X,
- m_list_sortparticledistribution[i].RectF.Y + ls_height,
- m_list_sortparticledistribution[i].RectF.Width,
- m_list_sortparticledistribution[i].GetSortGridHeight() + 50);//为每栏的高度增加了50补充,防止图像溢出
- }
- //然后再重新对分栏grid中的颗粒,重新进行摆放
- foreach (SortParticleDistribution ls_spd in m_list_sortparticledistribution)
- {
- ls_spd.SortDParticle(FZOOMRecord);
- }
- //最后,将分栏grid,分别存放到old的分栏grid中
- foreach (SortParticleDistribution ls_sortparticledistribution in m_list_sortparticledistribution)
- {
- SortParticleDistribution old_sortparticledistribution = ls_sortparticledistribution.Clone() as SortParticleDistribution;
- m_old_list_sortparticledistribution.Add(old_sortparticledistribution);
- foreach (DParticle ls_dp in old_sortparticledistribution.List_DParticle)
- {
- ls_dp.Rect = ls_dp.GetRectFromDSegment();
- }
- }
- }
- /// <summary>
- /// 判断该点是否在多边形的范围内
- /// </summary>
- /// <param name="inPoints"></param>
- /// <param name="WhetherPoint"></param>
- /// <returns></returns>
- //private bool WhetherInRange(PointF[] inPoints, Point WhetherPoint)
- //{
- // bool b_inrange = false;
- // GraphicsPath myGraphicsPath = new GraphicsPath();
- // Region myRegion = new Region();
- // myGraphicsPath.Reset();
- // myGraphicsPath.AddPolygon(inPoints);
- // myRegion.MakeEmpty();
- // myRegion.Union(myGraphicsPath);
- // //返回判断点是否在多边形里
- // b_inrange = myRegion.IsVisible(WhetherPoint);
- // return b_inrange;
- //}
- ///// <summary>
- ///// 判断该点是否在多边形的范围内的float版本重载
- ///// </summary>
- ///// <param name="inPoints"></param>
- ///// <param name="WhetherPoint"></param>
- ///// <returns></returns>
- //private bool WhetherInRange(PointF[] inPoints, PointF WhetherPoint)
- //{
- // bool b_inrange = false;
- // GraphicsPath myGraphicsPath = new GraphicsPath();
- // Region myRegion = new Region();
- // myGraphicsPath.Reset();
- // myGraphicsPath.AddPolygon(inPoints);
- // myRegion.MakeEmpty();
- // myRegion.Union(myGraphicsPath);
- // //返回判断点是否在多边形里
- // b_inrange = myRegion.IsVisible(WhetherPoint);
- // return b_inrange;
- //}
-
- /// <summary>
- /// 是否显示标尺控件,自动切换显示与不显示
- /// </summary>
- /// <param name="b_show"></param>
- public void ShowRulerControl()
- {
- control_Ruler1.Visible = !control_Ruler1.Visible;
- }
- /// <summary>
- /// 是否显示标尺控件,带参重载
- /// </summary>
- /// <param name="b_show"></param>
- public void ShowRulerControl(bool b_show)
- {
- control_Ruler1.Visible = b_show;
- }
- /// <summary>
- /// 设置显示BSE原图,还是显示排序图带有标准库的
- /// </summary>
- /// <param name="in_b">false为显示原bse图像,true为显示带有标准库代表色的图像</param>
- public void ShowMode(bool in_b)
- {
- if (in_b == false)
- {
- foreach (SortParticleDistribution item in m_list_sortparticledistribution)
- {
- foreach (DParticle ls_dp in item.List_DParticle)
- {
- foreach (DSegment ls_ds in ls_dp.DSegments)
- {
- ls_ds.ShowMode = SegmentShowMode.DRAWPOINT;
- }
- }
- }
- }
- else
- {
- foreach (SortParticleDistribution item in m_list_sortparticledistribution)
- {
- foreach (DParticle ls_dp in item.List_DParticle)
- {
- foreach (DSegment ls_ds in ls_dp.DSegments)
- {
- ls_ds.ShowMode = SegmentShowMode.DRAWLINE;
- }
- }
- }
- }
- this.Invalidate();
- }
- /// <summary>
- /// 对颗粒进行排序
- /// </summary>
- /// <param name="in_list_baseobject"></param>
- /// <param name="str_sort">排序的方法,从小到到,小大到小</param>
- public void SortDParticleBySize(List<BaseObject> in_list_baseobject, string str_sort)
- {
- List<DParticle> list_dp1 = new List<DParticle>();
- foreach (DParticle ls_dp in in_list_baseobject)
- {
- DParticle dp1 = ls_dp.Clone() as DParticle;
- list_dp1.Add(dp1);
- }
- in_list_baseobject.Clear();
- if (str_sort == "从小到大")
- {
- int icount = list_dp1.Count();
- for (int i = 0; i < icount; i++)
- {
- float f_min_size = 10000000;
- string str_jlguid = "";
- DParticle ls_dp = new DParticle();
- foreach (DParticle ls_del_dp in list_dp1)
- {
- ls_del_dp.FSize = ls_del_dp.GetSizeFormSegmentsAllWidth();
- if (f_min_size > ls_del_dp.FSize)
- {
- f_min_size = ls_del_dp.FSize;
- str_jlguid = ls_del_dp.ID;
- ls_dp = ls_del_dp;
- }
- }
- list_dp1.Remove(ls_dp);
- in_list_baseobject.Add(ls_dp);
- }
- }
- else if (str_sort == "从大到小")
- {
- int icount = list_dp1.Count();
- for (int i = 0; i < icount; i++)
- {
- float f_max_size = 0;
- string str_jlguid = "";
- DParticle ls_dp = new DParticle();
- foreach (DParticle ls_del_dp in list_dp1)
- {
- ls_del_dp.FSize = ls_del_dp.GetSizeFormSegmentsAllWidth();
- if (f_max_size < ls_del_dp.FSize)
- {
- f_max_size = ls_del_dp.FSize;
- str_jlguid = ls_del_dp.ID;
- ls_dp = ls_del_dp;
- }
- }
- list_dp1.Remove(ls_dp);
- ls_dp.Rect = ls_dp.GetRectFromDSegment();
- in_list_baseobject.Add(ls_dp);
- }
- }
- }
-
- /// <summary>
- /// 是否进行矩形多选操作
- /// </summary>
- public void MultiSelect_Rectangle()
- {
- if (m_is_multiselect_ellipse == true)
- {
- m_is_multiselect_ellipse = false;
- }
- m_is_multiselect_rectangle = true;
- }
- /// <summary>
- /// 是否进行圆形多选操作
- /// </summary>
- public void MultiSelect_Ellipse()
- {
- if (m_is_multiselect_rectangle == true)
- {
- m_is_multiselect_rectangle = false;
- }
- m_is_multiselect_ellipse = true;
- }
- /// <summary>
- /// 对选择的多边形进行反选操作
- /// </summary>
- public void ReverSeSelection()
- {
- foreach (SortParticleDistribution aag in m_list_sortparticledistribution)
- {
- foreach (DParticle dp in aag.List_DParticle)
- {
- if (ParticleOperator.DISPLAY == dp.Operator)
- {
- dp.Operator = ParticleOperator.SELECTED;
- }
- else if (ParticleOperator.SELECTED == dp.Operator)
- {
- dp.Operator = ParticleOperator.DISPLAY;
- }
- }
- }
- //将排列图选择的颗粒传送给报告框架中
- SelectParticleListSendToReportFrame();
- this.Invalidate();
- }
- /// <summary>
- /// 取消所有的颗粒的选择状态
- /// </summary>
- public void DeselectAllParticle()
- {
- foreach (SortParticleDistribution aag in m_list_sortparticledistribution)
- {
- foreach (DParticle dp in aag.List_DParticle)
- {
- if (ParticleOperator.SELECTED == dp.Operator)
- {
- dp.Operator = ParticleOperator.DISPLAY;
- }
- }
- }
- //将排列图选择的颗粒传送给报告框架中
- SelectParticleListSendToReportFrame();
- this.Invalidate();
- }
- /// <summary>
- /// 将整个图像拷贝到内存中
- /// </summary>
- public void CopyToBitmap()
- {
- Bitmap bp = new Bitmap(this.Size.Width, this.Size.Height);
- this.DrawToBitmap(bp, new Rectangle(0, 0, this.Size.Width, this.Size.Height));
- Clipboard.SetImage(bp);
- }
- #endregion
- #region 鼠标菜单右键
- private void ToolStripMenuItem_id_Click(object sender, EventArgs e)
- {
- //ID
- DParticle dp = (DParticle)CMenuStrip.Items[0].Tag;
- MessageBox.Show(dp.ID.ToString());
- }
- private void ToolStripMenuItem_selected_Click(object sender, EventArgs e)
- {
- //选择
- DParticle dp = (DParticle)CMenuStrip.Items[0].Tag;
- if (ParticleOperator.SELECTED == dp.Operator)
- {
- dp.Operator = ParticleOperator.DISPLAY;
- CMenuStrip.Items[1].Text = "选择颗粒";
- control_XRayTable1.Visible = false;
- }
- else
- {
- dp.Operator = ParticleOperator.SELECTED;
- CMenuStrip.Items[1].Text = "取消颗粒选择";
- }
- //将排列图选择的颗粒传送给报告框架中
- SelectParticleListSendToReportFrame();
- }
- private void ToolStripMenuItem_delete_Click(object sender, EventArgs e)
- {
- //删除颗粒
- DParticle dp = (DParticle)CMenuStrip.Items[0].Tag;
- //同样,要在历史操作记录类中,添加记录,好可以进行撤消操作
- HistoryApolygon hApolygon = new HistoryApolygon();
- hApolygon.APolygonID = dp.ID;
- hApolygon.Operator = ParticleOperator.DELETED;
- hApolygon.OldOperator = dp.Operator;
- hApolygon.ID = m_list_historyapolygon.Count;
- m_list_historyapolygon.Add(hApolygon);
- m_operator_currentid = hApolygon.ID;//当前操作到的历史操作记录
- //设置颗粒的状态为已经被删除
- dp.Operator = ParticleOperator.DELETED;
- }
- private void ToolStripMenuItem_movesempoint_Click(object sender, EventArgs e)
- {
- //移动SEM到指定位置
- if (m_mythread == null)
- {
- return;
- }
- if (m_mythread.ThreadState == ThreadState.Running || m_mythread.ThreadState == ThreadState.WaitSleepJoin)
- {
- return;
- }
- if (m_mythread.ThreadState == ThreadState.Stopped)
- {
- m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
- }
- if (m_sem_mouse_now_point.X != 0 && m_sem_mouse_now_point.Y != 0)
- {
- //改为线程调用,先判断线程状态
- m_mythread.Start(new Point(m_sem_mouse_now_point.X, m_sem_mouse_now_point.Y));
- }
- }
- //复制图像
- private void ToolStripMenuItem_copyimage_Click(object sender, EventArgs e)
- {
- CopyImage();
- }
- //显示过小颗粒
- private void ToolStripMenuItemShowSmallParticle_Click(object sender, EventArgs e)
- {
- if (bShowSmallParticle == false)
- {
- bShowSmallParticle = true;
- CMenuStrip.Items[6].Text = "不显示过小颗粒";
- }
- else
- {
- bShowSmallParticle = false;
- CMenuStrip.Items[6].Text = "显示过小颗粒";
- }
- //缩放的增大缩小的增量
- m_f_zoom_increment = 0.1f;
- //缩放的基数,临时变量
- m_f_widthandheight_js = 0;
- //与原先缩放的记录数
- m_f_zoom_record = 1;
- //最大缩放倍数
- m_f_zoom_max = 4f;
- //最小缩放倍数
- m_f_zoom_mix = 0.5f;
- //标尺的大小记录
- m_f_ruler_size = 100;
- //标尺原先大小的记录,参与计算
- m_f_old_ruler_size = 100;
- //每像素代表的尺寸大小,还不知道在哪里进行计算
- m_f_onepixel_size = 4.5f;
- //提供鼠标在右下角显示的文本,左侧
- m_str_mouseshow_left = "";
- //提供鼠标在右下角显示的文本,右侧
- m_str_mouseshow_right = "";
- //分栏网格边框的颜色
- m_c_ColumnRectangleColor = Color.LightSteelBlue;
- //记录操作记录类
- m_list_historyapolygon = null;
- //操作历史类,当前操作到的id
- m_operator_currentid = 0;
- m_list_baseobject = new List<BaseObject>();
- m_list_historyapolygon = new List<HistoryApolygon>();
- m_list_sortparticledistribution = new List<SortParticleDistribution>();
- m_old_list_sortparticledistribution = new List<SortParticleDistribution>();
- m_mythread_state = false;
- m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
- m_frm_userprogress = new Frm_UserProgress();
- Control_DrawDistrbutionSortImage_Load(null, null);
- GetDistrbutionSortimage_ByQuery(m_list_cgriddataclr);
- }
- #endregion
- }
- }
|