Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 (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 #include <mitkIOUtil.h>
21 
22 //##Documentation
23 //## @brief Load one or more data sets (many image, surface
24 //## and other formats) 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(
32  stderr, "Usage: %s [filename1] [filename2] ...\n\n", itksys::SystemTools::GetFilenameName(argv[0]).c_str());
33  return 1;
34  }
35 
36  // Register Qmitk-dependent global instances
38 
39  //*************************************************************************
40  // Part I: Basic initialization
41  //*************************************************************************
42 
43  // Create a data storage object. We will use it as a singleton
45 
46  //*************************************************************************
47  // Part II: Create some data by reading files
48  //*************************************************************************
49  int i;
50  for (i = 1; i < argc; ++i)
51  {
52  // For testing
53  if (strcmp(argv[i], "-testing") == 0)
54  continue;
55 
56  //*********************************************************************
57  // Part III: Put the data into the datastorage
58  //*********************************************************************
59  // Add the node to the DataStorage
60  mitk::IOUtil::Load(argv[i], *storage);
61  }
62 
63  //*************************************************************************
64  // Part IV: Create window and pass the datastorage to it
65  //*************************************************************************
66 
67  // Create a RenderWindow
68  QmitkRenderWindow renderWindow;
69 
70  // Tell the RenderWindow which (part of) the datastorage to render
71  renderWindow.GetRenderer()->SetDataStorage(storage);
72 
73  // Initialize the RenderWindow
74  auto geo = storage->ComputeBoundingGeometry3D(storage->GetAll());
76 
77  // Select a slice
79  if (sliceNaviController)
80  sliceNaviController->GetSlice()->SetPos(2);
81 
82  //*************************************************************************
83  // Part V: Qt-specific initialization
84  //*************************************************************************
85  renderWindow.show();
86  renderWindow.resize(256, 256);
87 
88  return qtapplication.exec();
89 }
90 
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace=false)
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:25
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