diff --git a/Applications/Tutorial/Step1.cpp b/Applications/Tutorial/Step1.cpp index d97a7ecc92..295d1f596f 100644 --- a/Applications/Tutorial/Step1.cpp +++ b/Applications/Tutorial/Step1.cpp @@ -1,122 +1,116 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkRegisterClasses.h" #include "QmitkRenderWindow.h" -#include +#include #include #include #include //##Documentation //## @brief Load image (pic format) and display it in a 2D view int main(int argc, char* argv[]) { QApplication qtapplication( argc, argv ); if (argc < 2) { fprintf( stderr, "Usage: %s [filename] \n\n", itksys::SystemTools::GetFilenameName(argv[0]).c_str() ); return 1; } // Register Qmitk-dependent global instances QmitkRegisterClasses(); //************************************************************************* // Part I: Basic initialization //************************************************************************* // Create a DataStorage // The DataStorage manages all data objects. It is used by the // rendering mechanism to render all data objects // We use the standard implementation mitk::StandaloneDataStorage. mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); //************************************************************************* // Part II: Create some data by reading a file //************************************************************************* - // Create a PicFileReader to read a .pic-file - mitk::PicFileReader::Pointer reader = mitk::PicFileReader::New(); + // Create a DataNodeFactory to read a data format supported + // by the DataNodeFactory (many image formats, surface formats, etc.) + mitk::DataNodeFactory::Pointer reader=mitk::DataNodeFactory::New(); const char * filename = argv[1]; try { reader->SetFileName(filename); reader->Update(); + //************************************************************************* + // Part III: Put the data into the datastorage + //************************************************************************* + + // Add the node to the DataStorage + ds->Add(reader->GetOutput()); } catch(...) { fprintf( stderr, "Could not open file %s \n\n", filename ); exit(2); } - //************************************************************************* - // Part III: Put the data into the datastorage - //************************************************************************* - - // Create a node and add the Image (which is read from the file) to it - mitk::DataNode::Pointer node = mitk::DataNode::New(); - node->SetData(reader->GetOutput()); - - // Add the node to the DataStorage - ds->Add(node); - - //************************************************************************* // Part IV: Create window and pass the datastorage to it //************************************************************************* // Create a RenderWindow QmitkRenderWindow renderWindow; // Tell the RenderWindow which (part of) the datastorage to render renderWindow.GetRenderer()->SetDataStorage(ds); // Initialize the RenderWindow mitk::TimeSlicedGeometry::Pointer geo = ds->ComputeBoundingGeometry3D(ds->GetAll()); mitk::RenderingManager::GetInstance()->InitializeViews( geo ); //mitk::RenderingManager::GetInstance()->InitializeViews(); // Select a slice mitk::SliceNavigationController::Pointer sliceNaviController = renderWindow.GetSliceNavigationController(); if (sliceNaviController) sliceNaviController->GetSlice()->SetPos( 0 ); //************************************************************************* // Part V: Qt-specific initialization //************************************************************************* renderWindow.show(); renderWindow.resize( 256, 256 ); // for testing #include "QtTesting.h" if (strcmp(argv[argc-1], "-testing") != 0) return qtapplication.exec(); else return QtTesting(); - // cleanup: Remove References to node and DataStorage. This will delete the two objects - node = NULL; + // cleanup: Remove References to DataStorage. This will delete the object ds = NULL; } /** \example Step1.cpp */