Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
Step1.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "QmitkRegisterClasses.h"
14 #include "QmitkRenderWindow.h"
15 
17 
18 #include <QApplication>
19 #include <itksys/SystemTools.hxx>
20 
21 #include <mitkIOUtil.h>
22 
23 //##Documentation
24 //## @brief Load image (nrrd format) and display it in a 2D view
25 int 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
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.
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());
68  // mitk::RenderingManager::GetInstance()->InitializeViews();
69 
70  // Select a slice
72  if (sliceNaviController)
73  sliceNaviController->GetSlice()->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 }
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace=false)
int main(int argc, char *argv[])
Load image (nrrd format) and display it in a 2D view.
Definition: Step1.cpp:25
void SetDataStorage(mitk::DataStorage *storage) override
set the datastorage that will be used for rendering
MITKQTWIDGETS_EXPORT void QmitkRegisterClasses()
static RenderingManager * GetInstance()
MITK implementation of the QVTKWidget.
virtual mitk::VtkPropRenderer * GetRenderer()
virtual mitk::SliceNavigationController * GetSliceNavigationController()
static DataStorage::SetOfObjects::Pointer Load(const std::string &path, DataStorage &storage, const ReaderOptionsFunctorBase *optionsCallback=nullptr)
Load a file into the given DataStorage.
Definition: mitkIOUtil.cpp:489