Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
Step2.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 #include <mitkIOUtil.h>
25 
26 //##Documentation
27 //## @brief Load one or more data sets (many image, surface
28 //## and other formats) 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(
36  stderr, "Usage: %s [filename1] [filename2] ...\n\n", itksys::SystemTools::GetFilenameName(argv[0]).c_str());
37  return 1;
38  }
39 
40  // Register Qmitk-dependent global instances
42 
43  //*************************************************************************
44  // Part I: Basic initialization
45  //*************************************************************************
46 
47  // Create a data storage object. We will use it as a singleton
49 
50  //*************************************************************************
51  // Part II: Create some data by reading files
52  //*************************************************************************
53  int i;
54  for (i = 1; i < argc; ++i)
55  {
56  // For testing
57  if (strcmp(argv[i], "-testing") == 0)
58  continue;
59 
60  //*********************************************************************
61  // Part III: Put the data into the datastorage
62  //*********************************************************************
63  // Add the node to the DataStorage
64  mitk::IOUtil::Load(argv[i], *storage);
65  }
66 
67  //*************************************************************************
68  // Part IV: Create window and pass the datastorage to it
69  //*************************************************************************
70 
71  // Create a RenderWindow
72  QmitkRenderWindow renderWindow;
73 
74  // Tell the RenderWindow which (part of) the datastorage to render
75  renderWindow.GetRenderer()->SetDataStorage(storage);
76 
77  // Initialize the RenderWindow
78  mitk::TimeGeometry::Pointer geo = storage->ComputeBoundingGeometry3D(storage->GetAll());
80 
81  // Select a slice
83  if (sliceNaviController)
84  sliceNaviController->GetSlice()->SetPos(2);
85 
86  //*************************************************************************
87  // Part V: Qt-specific initialization
88  //*************************************************************************
89  renderWindow.show();
90  renderWindow.resize(256, 256);
91 
92 // for testing
93 #include "QtTesting.h"
94  if (strcmp(argv[argc - 1], "-testing") != 0)
95  return qtapplication.exec();
96  else
97  return QtTesting();
98 }
99 
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace=false)
virtual void SetDataStorage(mitk::DataStorage *storage) override
set the datastorage that will be used for rendering
int main(int argc, char *argv[])
Load one or more data sets (many image, surface and other formats) and display it in a 2D view...
Definition: Step2.cpp:29
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