Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "QmitkRegisterClasses.h"
18 #include "QmitkRenderWindow.h"
19 
21 
22 #include <QApplication>
23 #include <itksys/SystemTools.hxx>
24 
25 #include <mitkIOUtil.h>
26 
27 //##Documentation
28 //## @brief Load image (nrrd format) and display it in a 2D view
29 int main(int argc, char *argv[])
30 {
31  QApplication qtapplication(argc, argv);
32 
33  if (argc < 2)
34  {
35  fprintf(stderr, "Usage: %s [filename] \n\n", itksys::SystemTools::GetFilenameName(argv[0]).c_str());
36  return 1;
37  }
38 
39  // Register Qmitk-dependent global instances
41 
42  //*************************************************************************
43  // Part I: Basic initialization
44  //*************************************************************************
45 
46  // Create a DataStorage
47  // The DataStorage manages all data objects. It is used by the
48  // rendering mechanism to render all data objects
49  // We use the standard implementation mitk::StandaloneDataStorage.
51 
52  //*************************************************************************
53  // Part II: Create some data by reading a file
54  //*************************************************************************
55 
56  // Load datanode (eg. many image formats, surface formats, etc.)
57  mitk::IOUtil::Load(argv[1], *ds);
58 
59  //*************************************************************************
60  // Part IV: Create window and pass the datastorage to it
61  //*************************************************************************
62 
63  // Create a RenderWindow
64  QmitkRenderWindow renderWindow;
65 
66  // Tell the RenderWindow which (part of) the datastorage to render
67  renderWindow.GetRenderer()->SetDataStorage(ds);
68 
69  // Initialize the RenderWindow
70  mitk::TimeGeometry::Pointer geo = ds->ComputeBoundingGeometry3D(ds->GetAll());
72  // mitk::RenderingManager::GetInstance()->InitializeViews();
73 
74  // Select a slice
76  if (sliceNaviController)
77  sliceNaviController->GetSlice()->SetPos(0);
78 
79  //*************************************************************************
80  // Part V: Qt-specific initialization
81  //*************************************************************************
82  renderWindow.show();
83  renderWindow.resize(256, 256);
84 
85 // for testing
86 #include "QtTesting.h"
87  if (strcmp(argv[argc - 1], "-testing") != 0)
88  return qtapplication.exec();
89  else
90  return QtTesting();
91 
92  // cleanup: Remove References to DataStorage. This will delete the object
93  ds = NULL;
94 }
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:29
virtual 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()
int QtTesting()
Definition: QtTesting.cpp:22
virtual mitk::SliceNavigationController * GetSliceNavigationController()
static DataStorage::SetOfObjects::Pointer Load(const std::string &path, DataStorage &storage)
Load a file into the given DataStorage.
Definition: mitkIOUtil.cpp:483