private void CreateScalarBar() { // Initialize ScalarBar actor ScalarBar = vtkScalarBarActor.New(); ScalarBar.SetLookupTable(colorLookupTable); // Assign default number of colors and label format ScalarBar.SetNumberOfLabels(10); ScalarBar.SetLabelFormat("%.2e"); TextProp = vtkTextProperty.New(); TextProp.SetFontSize(12); TextProp.SetBold(0); TextProp.SetFontFamilyToArial(); TextProp.ItalicOff(); TextProp.SetJustificationToLeft(); TextProp.SetVerticalJustificationToBottom(); TextProp.ShadowOff(); TextProp.SetColor(1, 1, 1); ScalarBar.SetTitleTextProperty(TextProp); ScalarBar.SetLabelTextProperty(TextProp); // Assign default size of Scalar Bar ScalarBar.SetMaximumWidthInPixels(120); ScalarBar.SetPosition(0.015, 0.10); ScalarBar.SetPosition2(0.16, 0.90); //Hide ScalarBar ScalarBar.VisibilityOff(); //Add to Viewport Viewport.AddActor2D(ScalarBar); }
private void ReadDICOMSeries() { // Path to vtk data must be set as an environment variable // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0" vtkTesting test = vtkTesting.New(); string root = test.GetDataRoot(); // Read all the DICOM files in the specified directory. // Caution: folder "DicomTestImages" don't exists by default in the standard vtk data folder // sample data are available at http://www.vtk.org/Wiki/images/1/12/VTK_Examples_StandardFormats_Input_DicomTestImages.zip //string folder = Path.Combine(root, @"Data\DicomTestImages"); string folder = @"provaDicom/" + studyUID; Console.WriteLine(folder); vtkDICOMImageReader reader = vtkDICOMImageReader.New(); reader.SetDirectoryName(folder); reader.Update(); // Visualize _ImageViewer = vtkImageViewer2.New(); _ImageViewer.SetInputConnection(reader.GetOutputPort()); // get range of slices (min is the first index, max is the last index) _ImageViewer.GetSliceRange(ref _MinSlice, ref _MaxSlice); Debug.WriteLine("slices range from : " + _MinSlice.ToString() + " to " + _MaxSlice.ToString()); // slice status message vtkTextProperty sliceTextProp = vtkTextProperty.New(); sliceTextProp.SetFontFamilyToCourier(); sliceTextProp.SetFontSize(20); sliceTextProp.SetVerticalJustificationToBottom(); sliceTextProp.SetJustificationToLeft(); _SliceStatusMapper = vtkTextMapper.New(); _SliceStatusMapper.SetInput("Slice No " + (_Slice + 1).ToString() + "/" + (_MaxSlice + 1).ToString()); _SliceStatusMapper.SetTextProperty(sliceTextProp); vtkActor2D sliceStatusActor = vtkActor2D.New(); sliceStatusActor.SetMapper(_SliceStatusMapper); sliceStatusActor.SetPosition(15, 10); // usage hint message vtkTextProperty usageTextProp = vtkTextProperty.New(); usageTextProp.SetFontFamilyToCourier(); usageTextProp.SetFontSize(14); usageTextProp.SetVerticalJustificationToTop(); usageTextProp.SetJustificationToLeft(); vtkTextMapper usageTextMapper = vtkTextMapper.New(); usageTextMapper.SetInput("Slice with mouse wheel\nor Up/Down-Key"); usageTextMapper.SetTextProperty(usageTextProp); vtkActor2D usageTextActor = vtkActor2D.New(); usageTextActor.SetMapper(usageTextMapper); usageTextActor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay(); usageTextActor.GetPositionCoordinate().SetValue(0.05, 0.95); vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; vtkInteractorStyleImage interactorStyle = vtkInteractorStyleImage.New(); // NOTA:non funziona la rotellina del mouse per cambiare slice <-------------------------------------- // l'errore è causato dalla funzione DicomCFindRequest(della sorgente di FellowOak) //in QueryFellowOak.cs, in particolare dal costruttore // DicomCFindRequest(DicomQueryRetrieveLevel level) // interactorStyle.MouseWheelForwardEvt += new vtkObject.vtkObjectEventHandler(interactor_MouseWheelForwardEvt); // interactorStyle.MouseWheelBackwardEvt += new vtkObject.vtkObjectEventHandler(interactor_MouseWheelBackwardEvt); renderWindow.GetInteractor().SetInteractorStyle(interactorStyle); renderWindow.GetRenderers().InitTraversal(); vtkRenderer ren; while ((ren = renderWindow.GetRenderers().GetNextItem()) != null) { ren.SetBackground(0.0, 0.0, 0.0); } _ImageViewer.SetRenderWindow(renderWindow); _ImageViewer.GetRenderer().AddActor2D(sliceStatusActor); _ImageViewer.GetRenderer().AddActor2D(usageTextActor); _ImageViewer.SetSlice(_MinSlice); _ImageViewer.Render(); }