예제 #1
0
        /// <summary>
        /// Event fired when the graph selection is changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_SelectionChangedEvt(vtkObject sender, vtkObjectEventArgs e)
        {
            //Get the selection
            vtkDataRepresentation dr   = view.GetRepresentation(0);
            vtkAnnotationLink     al   = dr.GetAnnotationLink();
            vtkSelection          sel  = al.GetCurrentSelection();
            vtkAbstractArray      arr  = null;
            vtkSelectionNode      node = sel.GetNode(0);

            if (null != node)
            {
                arr = node.GetSelectionList();
            }

            vtkIdTypeArray arr1 = (vtkIdTypeArray)arr;

            // Short circuit if nothing is selected...
            int numSelected = (int)arr1.GetNumberOfTuples();

            if (0 == numSelected)
            {
                return;
            }

            vtkStringArray arr2 = ((vtkStringArray)g.GetVertexData().GetAbstractArray("label"));

            //get a pseudo random name if more than one are selected
            string name = arr2.GetValue(
                (int)arr1.GetValue(System.DateTime.Now.Millisecond % numSelected));

            //reset the small arrayList
            arrListSmall = new System.Collections.ArrayList();
            int hops;

            try
            {
                hops = System.Convert.ToInt32(toolStripTextBox3.Text);
            }
            catch (Exception)
            {
                hops = 1;
            }

            toolStripTextBox1.Text = name;
            toolStripTextBox1.Invalidate();
            this.Update();

            //Start the loading graphic and add another renderer on top for the spinning logo
            vtkRenderWindow win = this.renderWindowControl1.RenderWindow;

            win.AddRenderer(logoRenderer);
            win.Render();
            this.webBrowser1.Url = new Uri("http://en.wikipedia.org/wiki/" + name.Replace(" ", "_"));
            //Start the work
            addLinks(g, name, hops);
            //Remove the spinning logo after the work is done
            win.RemoveRenderer(logoRenderer);
            win.Render();
        }
예제 #2
0
        /// <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();
        }
예제 #3
0
        //Buttons

        //Load CT data
        private void fileButton_Click(object sender, EventArgs e)
        {
            label4.Text        = "Loading: ";
            mainProgress.Value = 10;
            //Select a file and render volume
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                if (is_rendering == 1)
                {
                    //Remove renderer
                    renWin.RemoveRenderer(renWin.GetRenderers().GetFirstRenderer());
                    volume.Dispose();
                    volume = null;
                    GC.Collect();
                }

                //Initialize new volume
                volume = new Rendering.renderPipeLine();

                //Update renderwindow
                renderWindowControl_Load(this, null);

                fname = "";

                //Get path and files
                string impath  = fileDialog.FileName;
                string folpath = Path.GetDirectoryName(@impath);

                // Get sample name
                var file = Path.GetFileName(impath).Split('_');
                for (int k = 0; k < file.Length - 1; k++)
                {
                    fname += file[k];
                    if (k < file.Length - 2)
                    {
                        fname += "_";
                    }
                }
                mainProgress.Value = 50;

                //Load data
                volume.connectData(impath);
                mainProgress.Value = 70;

                //Get dimensions and set slices. Middle slice is set to current slice
                dims      = volume.getDims();
                sliceN[0] = (dims[1] + dims[0]) / 2;
                sliceN[1] = (dims[3] + dims[2]) / 2;
                sliceN[2] = (dims[5] + dims[4]) / 2;

                Console.WriteLine("Loaded fine");
                //Connect slice to renderer
                volume.connectWindow(renWin);

                Console.WriteLine("Connected window fine");
                //Render
                bool large = volume.renderVolume();
                if (large)
                {
                    Console.WriteLine("Too large sample. Memory limit is 2GB.");
                    return;
                }
                Console.WriteLine("rendering..");

                //Flags for GUI components
                is_rendering = 1;
                is_mask      = 0;
                is_coronal   = 0;
                is_sagittal  = 0;
                //Saving flags
                save_mask = 0;
                save_vois = 0;

                //Orientation
                ori = -1;
                //Update pipeline parameters
                volume.updateCurrent(sliceN, ori, gray);
                volume.setVolumeColor();

                //Update GUI
                maskButton.Text     = "Load Mask";
                maskLabel.Text      = "No Mask Loaded";
                coronalButton.Text  = "Coronal, XZ";
                sagittalButton.Text = "Sagittal, YZ";
                TellSlice();

                // Enable buttons
                sagittalButton.Enabled   = true;
                coronalButton.Enabled    = true;
                transverseButton.Enabled = true;
                volumeButton.Enabled     = true;
                resetButton.Enabled      = true;
                gminBar.Enabled          = true;
                gmaxBar.Enabled          = true;
                maskButton.Enabled       = true;
                panel2.Enabled           = true;
                sliceBar.Enabled         = true;
                if (!large)
                {
                    renderWindowControl.Enabled = true;
                }
                cropButton.Enabled    = true;
                rotate_button.Enabled = true;
                getVoiButton.Enabled  = false;
                segmentButton.Enabled = false;
                predict.Enabled       = false;
                saveButton.Enabled    = false;

                GC.Collect();

                //Update GUI text to tell path to data folder
                fileLabel.Text     = fname;
                tip                = "Sample loaded and tools enabled";
                gradeLabel.Text    = tip;
                mainProgress.Value = 100;
                label4.Text        = "Done";
            }
        }