public SplamModel(List <DataSeries> datas) { Series = new List <DataSeries>(datas); var colors = ColorConv.pickIsoCols(74.0f, Series.Count, .5f, (float)Math.PI); for (int i = 0; i < Series.Count; i++) { Series[i].Color = colors[i]; } SplatList = new List <SplatterModel>(); Iindex = new List <int>(); Jindex = new List <int>(); numDim = datas.First().ColumnNames.Count; dimNames = datas.First().ColumnNames; for (int i = 0; i < numDim - 1; i++) { for (int j = i + 1; j < numDim; j++) { var spm = new SplatterModel(Series, i, j, false); SplatList.Add(spm); Iindex.Add(i); Jindex.Add(j); } } }
static void ColorCombos() { StringBuilder text = new StringBuilder(); var colors = ColorConv.pickIsoColsVec(74.0f, 5, .5f, (float)Math.PI); List <List <int> > combos = new List <List <int> >(); int num = colors.Count; for (int i = 0; i < Math.Pow(2, num) - 1; i++) { var bits = new BitArray(new int[] { i + 1 }); var subl = new List <int>(); for (int j = 0; j < num; j++) { if (bits[j]) { subl.Add(j); } } if (subl.Count > 0) { combos.Add(subl); } } var sortedCombos = from combo in combos orderby combo.Count, combo.Sum() let sorted = combo.OrderBy(i => i).ToList() select sorted; foreach (var combo in sortedCombos) { combo.ForEach(i => text.Append("[" + i + "] ")); text.Append(" => "); var col = ColorConv.PerceptualBlendRGB(combo.Select(index => colors[index]).ToList(), 1.0f, 1.12f); text.Append(string.Format("({0}, {1}, {2})", (int)(col.X * 255), (int)(col.Y * 255), (int)(col.Z * 255))); text.AppendLine(); } string str = text.ToString(); System.Console.WriteLine(str); }
public SplatterModel(List <DataSeries> datas, string dim0N, string dim1N, bool calcColors) { Groups = new Dictionary <string, ISeriesProjection>(); Series = new Dictionary <string, SeriesProjection>(); dim0Name = dim0N; dim1Name = dim1N; xmax = float.MinValue; xmin = float.MaxValue; ymax = float.MinValue; ymin = float.MaxValue; showAllPoints = true; for (int i = 0; i < datas.Count; i++) { SeriesProjection sp = new SeriesProjection(); sp.Init(datas[i], dim0Name, dim1Name); Series[datas[i].Name] = sp; xmax = Math.Max(xmax, sp.Xmax); xmin = Math.Min(xmin, sp.Xmin); ymax = Math.Max(ymax, sp.Ymax); ymin = Math.Min(ymin, sp.Ymin); } SeriesMemberships = new BindingList <SeriesMembership>(); int j = 0; foreach (var series in Series.Values) { SeriesMemberships.Add(new SeriesMembership(series, j)); j++; } NumberOfGroups = Math.Min(Series.Count, 8); if (NumberOfGroups == Series.Count && !calcColors) { GroupColors = Series.Values.Select(s => s.Color).ToList(); } else { GroupColors = ColorConv.pickIsoCols(74.0f, NumberOfGroups, .5f, (float)Math.PI); } SetGroupMembers(); SeriesMemberships.ListChanged += new ListChangedEventHandler(SeriesMemberships_ListChanged); }
public OneVsAllModel(List <List <DataSeries> > splats, string dim0, string dim1) { SplatList = new List <SplatterModel>(); Groups = new List <DataSeries>(); Others = new List <DataSeries>(); OthersName = splats[0][1].Name; var colors = ColorConv.pickIsoCols(74.0f, splats.Count, .5f, (float)Math.PI); OtherColor = Color.Beige; int i = 0; foreach (var datas in splats) { Groups.Add(datas[0]); Others.Add(datas[1]); datas[0].Color = colors[i]; datas[1].Color = OtherColor; var sm = new SplatterModel(datas, dim0, dim1, false); SplatList.Add(sm); i++; } }
void drawPoints(ISeriesProjection series) { GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); GL.Enable(EnableCap.PointSmooth); float range = Math.Max(series.Xmax - series.Xmin, series.Ymax - series.Ymin); DensityRenderer renderer = m_DensityMap[series.Name]; int num = (int)(Math.Ceiling(Width / m_ClutterWindow)); num = Math.Max(num, 1); int[] grid = new int[num * num]; float cellsize = range / num; float offx = transformX(0) - (float)(Math.Floor(transformX(0) / m_ClutterWindow) * m_ClutterWindow); float offy = transformY(0) - (float)(Math.Floor(transformY(0) / m_ClutterWindow) * m_ClutterWindow); var selectedList = new List <int>(grid.Length); var unselectedList = new List <int>(grid.Length); var allList = new List <int>(grid.Length); if (m_ClutterWindow == 0) { allList.AddRange(series.dataPoints.Select(d => d.Index)); unselectedList.AddRange(series.dataPoints.Select(d => d.Index)); } else { foreach (var p in m_DensityMap[series.Name].Points) { float xgl = transformX(p.X); float ygl = transformY(p.Y); int ix = (int)Math.Floor((xgl - offx) / m_ClutterWindow); int iy = (int)Math.Floor((ygl - offy) / m_ClutterWindow); bool allow = !(ix < 0 || ix >= num || iy < 0 || iy >= num); if (allow) { int count = grid[ix * num + iy]++; allow = allow && count == 0; } float clutterRad = renderer.GetDist(xgl, ygl) * 2.0f; if (clutterRad > m_ClutterWindow && allow) { allList.Add(p.Index); if (p.Selected) { selectedList.Add(p.Index); } else { unselectedList.Add(p.Index); } } } } //use vbo???////////////////////////////////////////////// GL.EnableClientState(ArrayCap.VertexArray); GL.DisableClientState(ArrayCap.ColorArray); GL.BindBuffer(BufferTarget.ArrayBuffer, m_VboMap[series.Name].vbo); GL.VertexPointer(3, VertexPointerType.Float, Vertex.Stride, 2 * Vector3.SizeInBytes); var unselectedVertices = unselectedList.ToArray(); var selectedVertices = selectedList.ToArray(); var allVertices = allList.ToArray(); GL.PointSize(5); Color modulated = ColorConv.Modulate(series.Color, .9f); GL.Color3(modulated); GL.DrawElements(BeginMode.Points, unselectedVertices.Length, DrawElementsType.UnsignedInt, unselectedVertices); GL.Color3(Color.FromArgb(0, 255, 0)); GL.DrawElements(BeginMode.Points, selectedVertices.Length, DrawElementsType.UnsignedInt, selectedVertices); GL.PointSize(3); GL.Color3(series.Color); GL.DrawElements(BeginMode.Points, allVertices.Length, DrawElementsType.UnsignedInt, allVertices); GL.DisableClientState(ArrayCap.VertexArray); GL.Disable(EnableCap.DepthTest); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); }