public void draw1020(Gdk.Drawable da) { if (!this.isregistered) { draw(da); return; } double headcirc = 0; double[,] lsrcpos = project1020(this.SrcPos3D, this.numSrc, out headcirc); double[,] ldetpos = project1020(this.DetPos3D, this.numDet, out headcirc); int width, height; da.GetSize(out width, out height); double dx, dy; dx = 10; dy = 10; width = width - 20; height = height - 20; double maxX = headcirc * 1.2; double minX = -1 * headcirc * 1.2; double maxY = headcirc * 1.2; double minY = -1 * headcirc * 1.2; ROIdrawPos = new double[ROIs.Count, 2]; for (int i = 0; i < ROIs.Count; i++) { ROIdrawPos[i, 0] = minX - .1 * headcirc; ROIdrawPos[i, 1] = minY - .2 * (i) * headcirc; } if (ROIs.Count > 0) { minY = minY - (ROIs.Count) * .2 * headcirc; minX = minX - .1 * headcirc; } double rangeX = maxX - minX; double rangeY = maxY - minY; Gdk.GC gc = new Gdk.GC(da); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(0, 0, 0); Rectangle rarea = new Rectangle(); rarea.Height = height + 20; rarea.Width = width + 20; da.DrawRectangle(gc, true, rarea); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(255, 255, 255); rarea = new Rectangle(); rarea.Height = height + 18; rarea.Width = width + 18; rarea.X = 1; rarea.Y = 1; da.DrawRectangle(gc, true, rarea); int sz = 10; if (this.measlistAct == null) { this.measlistAct = new bool[this.ChannelMap.Length]; for (int i = 0; i < this.ChannelMap.Length; i++) { this.measlistAct[i] = false; } this.measlistAct[0] = true; } gc.RgbFgColor = new Gdk.Color(0, 0, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round); for (int i = 0; i < this.numChannels; i++) { if (this.ChannelMap[i].datasubtype.Equals(this.ChannelMap[0].datasubtype)) { if (this.measlistAct[i]) { gc.RgbFgColor = colormap[i]; //new Gdk.Color (0, 0, 0); } else { gc.RgbFgColor = new Gdk.Color(230, 230, 230); } int si = this.ChannelMap[i].sourceindex; int di = this.ChannelMap[i].detectorindex; double x1 = (ldetpos[di, 0] - minX) / rangeX * width + dx; double y1 = (ldetpos[di, 1] - minY) / rangeY * height + dy; double x2 = (lsrcpos[si, 0] - minX) / rangeX * width + dx; double y2 = (lsrcpos[si, 1] - minY) / rangeY * height + dy; da.DrawLine(gc, (int)x1, (int)y1, (int)x2, (int)y2); //pts[cnt]=new Gdk.Point((int)x,(int)y); } } gc.RgbFgColor = new Gdk.Color(0, 255, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); // Gdk.Point[] pts = new Gdk.Point[this.numdet+this.numsrc]; for (int i = 0; i < this.numDet; i++) { double x = (ldetpos[i, 0] - minX) / rangeX * width + dx - sz / 2; double y = (ldetpos[i, 1] - minY) / rangeY * height + dy - sz / 2; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); //pts[cnt]=new Gdk.Point((int)x,(int)y); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < this.numDet; i++) { double x = (ldetpos[i, 0] - minX) / rangeX * width + dx - sz / 2; double y = (ldetpos[i, 1] - minY) / rangeY * height + dy - sz / 2; Gtk.Label lab = new Gtk.Label(); lab.Text = string.Format("D{0}", i + 1); da.DrawLayout(gc, (int)x, (int)y, lab.Layout); } gc.RgbBgColor = new Gdk.Color(0, 255, 0); gc.RgbFgColor = new Gdk.Color(255, 0, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); for (int i = 0; i < this.numSrc; i++) { double x = (lsrcpos[i, 0] - minX) / rangeX * width + dx - sz / 2; double y = (lsrcpos[i, 1] - minY) / rangeY * height + dy - sz / 2; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < this.numSrc; i++) { double x = (lsrcpos[i, 0] - minX) / rangeX * width + dx - sz / 2; double y = (lsrcpos[i, 1] - minY) / rangeY * height + dy - sz / 2; Gtk.Label lab = new Gtk.Label(); lab.Text = string.Format("S{0}", i + 1); da.DrawLayout(gc, (int)x, (int)y, lab.Layout); } gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(0, 0, 0); double xx = (0) / rangeX * width + dx; double yy = (0) / rangeY * height + dy; da.DrawArc(gc, false, (int)xx, (int)yy, (int)(width), (int)(height), 0, 360 * 64); gc.RgbFgColor = new Gdk.Color(255, 0, 255); for (int i = 0; i < ROIs.Count; i++) { double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz / 2; double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < ROIs.Count; i++) { double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz; double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy; Gtk.Label lab = new Gtk.Label(); lab.Text = ROIs[i].name; da.DrawLayout(gc, (int)(x), (int)y, lab.Layout); } Gtk.Label lab2 = new Gtk.Label(); lab2.Text = "R"; da.DrawLayout(gc, (int)(width - 5), (int)(height - 5), lab2.Layout); }
public void draw2D(Gdk.Drawable da) { if (SrcPos == null) { return; } try { int width, height; da.GetSize(out width, out height); double dx, dy; dx = 20; dy = 20; width = width - 2 * (int)dy; height = height - 2 * (int)dx; double maxX, minX, maxY, minY; maxX = -999; maxY = -999; minX = 999; minY = 999; for (int i = 0; i < this.numDet; i++) { if (maxX < this.DetPos[i, 0]) { maxX = this.DetPos[i, 0]; } if (maxY < this.DetPos[i, 1]) { maxY = this.DetPos[i, 1]; } if (minX > this.DetPos[i, 0]) { minX = this.DetPos[i, 0]; } if (minY > this.DetPos[i, 1]) { minY = this.DetPos[i, 1]; } } for (int i = 0; i < this.numSrc; i++) { if (maxX < this.SrcPos[i, 0]) { maxX = this.SrcPos[i, 0]; } if (maxY < this.SrcPos[i, 1]) { maxY = this.SrcPos[i, 1]; } if (minX > this.SrcPos[i, 0]) { minX = this.SrcPos[i, 0]; } if (minY > this.SrcPos[i, 1]) { minY = this.SrcPos[i, 1]; } } ROIdrawPos = new double[ROIs.Count, 2]; for (int i = 0; i < ROIs.Count; i++) { ROIdrawPos[i, 0] = minX - .15 * (maxX - minX); ROIdrawPos[i, 1] = minY - .25 * (i + 1) * (maxY - minY); } if (ROIs.Count > 0) { minY = minY - (ROIs.Count + 1) * .25 * (maxY - minY); minX = minX - .15 * (maxX - minX); } double rangeX = maxX - minX; double rangeY = maxY - minY; Gdk.GC gc = new Gdk.GC(da); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(0, 0, 0); Rectangle rarea = new Rectangle(); rarea.Height = height + 2 * (int)dy; rarea.Width = width + 2 * (int)dx; da.DrawRectangle(gc, true, rarea); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(255, 255, 255); rarea = new Rectangle(); rarea.Height = height - 2 + 2 * (int)dx;; rarea.Width = width - 2 + 2 * (int)dx;; rarea.X = 1; rarea.Y = 1; da.DrawRectangle(gc, true, rarea); int sz = 10; if (this.measlistAct == null) { this.measlistAct = new bool[this.ChannelMap.Length]; for (int i = 0; i < this.ChannelMap.Length; i++) { this.measlistAct[i] = false; } this.measlistAct[0] = true; } gc.RgbFgColor = new Gdk.Color(0, 0, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round); for (int i = 0; i < this.numChannels; i++) { if (this.ChannelMap[i].datasubtype.Equals(this.ChannelMap[0].datasubtype)) { if (this.measlistAct[i]) { gc.RgbFgColor = colormap[i]; //new Gdk.Color (0, 0, 0); } else { gc.RgbFgColor = new Gdk.Color(230, 230, 230); } int si = this.ChannelMap[i].sourceindex; int di = this.ChannelMap[i].detectorindex; double x1 = (this.DetPos[di, 0] - minX) / rangeX * width; double y1 = height - ((this.DetPos[di, 1] - minY) / rangeY * height) + dy; double x2 = (this.SrcPos[si, 0] - minX) / rangeX * width; double y2 = height - ((this.SrcPos[si, 1] - minY) / rangeY * height) + dy; da.DrawLine(gc, (int)x1, (int)y1, (int)x2, (int)y2); //pts[cnt]=new Gdk.Point((int)x,(int)y); } } gc.RgbFgColor = new Gdk.Color(0, 255, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); // Gdk.Point[] pts = new Gdk.Point[this.numdet+this.numsrc]; for (int i = 0; i < this.numDet; i++) { double x = (this.DetPos[i, 0] - minX) / rangeX * width - sz / 2; double y = height - ((this.DetPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); //pts[cnt]=new Gdk.Point((int)x,(int)y); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < this.numDet; i++) { double x = (this.DetPos[i, 0] - minX) / rangeX * width - sz / 2; double y = height - ((this.DetPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy; Gtk.Label lab = new Gtk.Label(); lab.Text = string.Format("D{0}", i + 1); da.DrawLayout(gc, (int)x, (int)y, lab.Layout); } gc.RgbBgColor = new Gdk.Color(0, 255, 0); gc.RgbFgColor = new Gdk.Color(255, 0, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); for (int i = 0; i < this.numSrc; i++) { double x = (this.SrcPos[i, 0] - minX) / rangeX * width - sz / 2; double y = height - ((this.SrcPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < this.numSrc; i++) { double x = (this.SrcPos[i, 0] - minX) / rangeX * width - sz / 2; double y = height - ((this.SrcPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy; Gtk.Label lab = new Gtk.Label(); lab.Text = string.Format("S{0}", i + 1); da.DrawLayout(gc, (int)x, (int)y, lab.Layout); } gc.RgbFgColor = new Gdk.Color(255, 0, 255); for (int i = 0; i < ROIs.Count; i++) { double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz / 2; double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < ROIs.Count; i++) { double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz; double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy; Gtk.Label lab = new Gtk.Label(); lab.Text = ROIs[i].name; da.DrawLayout(gc, (int)(x), (int)y, lab.Layout); } Gtk.Label lab2 = new Gtk.Label(); lab2.Text = "L"; da.DrawLayout(gc, (int)(width - 5), (int)(height - 5), lab2.Layout); } catch { } return; }