MCPcopy Create free account
hub / github.com/MITK/MITK / main

Function main

Examples/Tutorial/Step1/Step1.cpp:25–82  ·  view source on GitHub ↗

#Documentation # @brief Load image (nrrd format) and display it in a 2D view

Source from the content-addressed store, hash-verified

23//##Documentation
24//## @brief Load image (nrrd format) and display it in a 2D view
25int main(int argc, char *argv[])
26{
27 QApplication qtapplication(argc, argv);
28
29 if (argc < 2)
30 {
31 fprintf(stderr, "Usage: %s [filename] \n\n", itksys::SystemTools::GetFilenameName(argv[0]).c_str());
32 return 1;
33 }
34
35 // Register Qmitk-dependent global instances
36 QmitkRegisterClasses();
37
38 //*************************************************************************
39 // Part I: Basic initialization
40 //*************************************************************************
41
42 // Create a DataStorage
43 // The DataStorage manages all data objects. It is used by the
44 // rendering mechanism to render all data objects
45 // We use the standard implementation mitk::StandaloneDataStorage.
46 mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New();
47
48 //*************************************************************************
49 // Part II: Create some data by reading a file
50 //*************************************************************************
51
52 // Load datanode (eg. many image formats, surface formats, etc.)
53 mitk::IOUtil::Load(argv[1], *ds);
54
55 //*************************************************************************
56 // Part IV: Create window and pass the datastorage to it
57 //*************************************************************************
58
59 // Create a RenderWindow
60 QmitkRenderWindow renderWindow;
61
62 // Tell the RenderWindow which (part of) the datastorage to render
63 renderWindow.GetRenderer()->SetDataStorage(ds);
64
65 // Initialize the RenderWindow
66 auto geo = ds->ComputeBoundingGeometry3D(ds->GetAll());
67 mitk::RenderingManager::GetInstance()->InitializeViews(geo);
68 // mitk::RenderingManager::GetInstance()->InitializeViews();
69
70 // Select a slice
71 mitk::SliceNavigationController::Pointer sliceNaviController = renderWindow.GetSliceNavigationController();
72 if (sliceNaviController)
73 sliceNaviController->GetStepper()->SetPos(0);
74
75 //*************************************************************************
76 // Part V: Qt-specific initialization
77 //*************************************************************************
78 renderWindow.show();
79 renderWindow.resize(256, 256);
80
81 return qtapplication.exec();
82}

Callers

nothing calls this directly

Calls 12

QmitkRegisterClassesFunction · 0.85
LoadFunction · 0.85
GetAllMethod · 0.80
GetStepperMethod · 0.80
showMethod · 0.80
NewFunction · 0.50
SetDataStorageMethod · 0.45
GetRendererMethod · 0.45
InitializeViewsMethod · 0.45
SetPosMethod · 0.45

Tested by

no test coverage detected