/// <summary> /// Clears the graph and makes a new one /// </summary> private void createNewGraph() { String lookupValue = toolStripTextBox1.Text; //clean up any old graph views in the renderer vtkMutableDirectedGraph g_temp = g; g = vtkMutableDirectedGraph.New(); if (g_temp != null) { g_temp.Dispose(); } //reset array lists arrListSmall = new System.Collections.ArrayList(); vtkStringArray label = vtkStringArray.New(); label.SetName("label"); //give the graph a starting point g.GetVertexData().AddArray(label); g.AddVertex(); label.InsertNextValue(lookupValue); arrListSmall.Add(lookupValue); int hops; try { hops = System.Convert.ToInt32(toolStripTextBox3.Text); } catch (Exception) { hops = 1; } //Start the loading graphic and switch renderers vtkRenderWindow win = this.renderWindowControl1.RenderWindow; win.AddRenderer(logoRenderer); win.Render(); this.webBrowser1.Url = new Uri("http://en.wikipedia.org/wiki/" + lookupValue.Replace(" ", "_")); //Start the work addLinks(g, lookupValue, hops); //Go back to the graph view after the work is done win.RemoveRenderer(logoRenderer); //Setup the view properties view.SetLayoutStrategyToSimple2D(); view.AddRepresentationFromInput(g); view.SetVertexLabelArrayName("label"); view.VertexLabelVisibilityOn(); view.SetVertexColorArrayName("VertexDegree"); view.ColorVerticesOn(); view.GetRenderer().ResetCamera(); view.Update(); }
/// <summary> /// Open a folder browser and graph the /// selected folder /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void setupView_Click(object sender, EventArgs e) { if (this.folderBrowserDialog1.ShowDialog().Equals(DialogResult.OK)) { //Add the view to the render window if (!initialized) { initialized = true; this.view.GetRenderWindow().SetParentId( this.renWinCTRL.RenderWindow.GetGenericWindowId()); this.ResizeTreeMapView(); //Add a handler to the view view.SelectionChangedEvt += new vtkObject.vtkObjectEventHandler(this.view_SelectionChangedEvt); } g = vtkMutableDirectedGraph.New(); vtkStringArray name = vtkStringArray.New(); name.SetName("name"); g.GetVertexData().AddArray(name); vtkStringArray path = vtkStringArray.New(); path.SetName("path"); g.GetVertexData().SetPedigreeIds(path); vtkLongLongArray size = vtkLongLongArray.New(); size.SetName("size"); g.GetVertexData().AddArray(size); string cur = Directory.GetCurrentDirectory(); buildTree(g, -1, this.folderBrowserDialog1.SelectedPath); this.label1.Text = "Viewing " + this.folderBrowserDialog1.SelectedPath; vtkTree t = vtkTree.New(); t.ShallowCopy(g); view.SetLayoutStrategyToSquarify(); view.SetAreaLabelArrayName("name"); view.SetAreaHoverArrayName("path"); view.SetAreaColorArrayName("level"); view.SetAreaSizeArrayName("size"); view.AddRepresentationFromInput(t); view.GetRenderer().ResetCamera(); view.Update(); view.Render(); } }
public void VTKLabelGetter(ref vtkPoints pointsrc, ref vtkStringArray strArr, ref vtkCellArray cellArr, FormParas paras, WorkSpaceClass WorkSpaceInstance) { Models.HeatDoublers hdlist = WorkSpaceInstance.HeatDoublerInstances; //MessageBox.Show(hdlist.listSize.ToString()); strArr.SetNumberOfValues(hdlist.listSize); strArr.SetName("111"); for (int i = 0; i < hdlist.listSize; i++) { pointsrc.InsertNextPoint(hdlist.list[i].X, 0, -hdlist.list[i].Y); strArr.SetValue(i, hdlist.list[i].Name); //MessageBox.Show(hdlist.list[i].Name); cellArr.InsertNextCell(1); cellArr.InsertCellPoint(i); } }