#Documentation # @brief Load image (nrrd format) and display it in a 2D view
| 29 | //##Documentation |
| 30 | //## @brief Load image (nrrd format) and display it in a 2D view |
| 31 | int main(int argc, char *argv[]) |
| 32 | { |
| 33 | QApplication qtapplication(argc, argv); |
| 34 | |
| 35 | if (argc < 2) |
| 36 | { |
| 37 | fprintf(stderr, "Usage: %s [filename] \n\n", itksys::SystemTools::GetFilenameName(argv[0]).c_str()); |
| 38 | return 1; |
| 39 | } |
| 40 | |
| 41 | // Register Qmitk-dependent global instances |
| 42 | QmitkRegisterClasses(); |
| 43 | |
| 44 | mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); |
| 45 | |
| 46 | // Load datanode (eg. many image formats, surface formats, etc.) |
| 47 | mitk::IOUtil::Load(argv[1], *ds); |
| 48 | |
| 49 | // Create a RenderWindow |
| 50 | QmitkRenderWindow renderWindow; |
| 51 | |
| 52 | // Tell the RenderWindow which (part of) the datastorage to render |
| 53 | renderWindow.GetRenderer()->SetDataStorage(ds); |
| 54 | |
| 55 | // Initialize the RenderWindow |
| 56 | auto geo = ds->ComputeBoundingGeometry3D(ds->GetAll()); |
| 57 | mitk::RenderingManager::GetInstance()->InitializeViews(geo); |
| 58 | // mitk::RenderingManager::GetInstance()->InitializeViews(); |
| 59 | |
| 60 | // Add Overlays |
| 61 | //![TextAnnotation2D] |
| 62 | // Create a textAnnotation2D |
| 63 | mitk::TextAnnotation2D::Pointer textAnnotation = mitk::TextAnnotation2D::New(); |
| 64 | |
| 65 | textAnnotation->SetText("Test!"); // set UTF-8 encoded text to render |
| 66 | textAnnotation->SetFontSize(40); |
| 67 | textAnnotation->SetColor(1, 0, 0); // Set text color to red |
| 68 | textAnnotation->SetOpacity(1); |
| 69 | |
| 70 | // The position of the Annotation can be set to a fixed coordinate on the display. |
| 71 | mitk::Point2D pos; |
| 72 | pos[0] = 10; |
| 73 | pos[1] = 20; |
| 74 | textAnnotation->SetPosition2D(pos); |
| 75 | |
| 76 | std::string rendererID = renderWindow.GetRenderer()->GetName(); |
| 77 | |
| 78 | // The LayoutAnnotationRenderer can place the TextAnnotation2D at some defined corner positions |
| 79 | mitk::LayoutAnnotationRenderer::AddAnnotation( |
| 80 | textAnnotation, rendererID, mitk::LayoutAnnotationRenderer::TopLeft, 5, 5, 1); |
| 81 | //![TextAnnotation2D] |
| 82 | |
| 83 | //![TextAnnotation3D] |
| 84 | mitk::PointSet::Pointer pointset = mitk::PointSet::New(); |
| 85 | |
| 86 | // This vector is used to define an offset for the annotations, in order to show them with a margin to the actual |
| 87 | // coordinate. |
| 88 | mitk::Point3D offset; |
nothing calls this directly
no test coverage detected