Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
MITKFltkExample.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 <string>
18 
19 #include <FL/Fl.h>
20 #include <FL/Fl_Window.h>
21 #include <FL/Fl_Box.h>
22 #include <Fl/Fl_File_Chooser.h>
23 #include "FLmitkRenderWindow/FLmitkRenderWindow.h"
24 
25 // #include "mitkIpPic.h"
26 #include "mitkPicFileReader.h"
27 
28 #include "mitkStringProperty.h"
31 
32 #include "mitkDataNodeFactory.h"
33 #include "mitkSample.h"
34 
35 int main(int argc, char **argv) {
36  const char* fileName = NULL;
37  if (argc == 2 && argv[1]) {
38  fileName = argv[1];
39  } else {
40  fileName = fl_file_chooser("Open file","*.dcm;*.png;*.jog;*.tiff;*.dcm;*.DCM;*.seq;*.pic;*.pic.gz;*.seq.gz;*.pic;*.pic.gz;*.png;*.stl",NULL);
41  }
42  if (!fileName) { exit(0);}
43 
44  UserInterface ui;
45  mitk::SliceNavigationController::Pointer &sliceCtrl = ui.mainWid->sliceCtrl;
46  sliceCtrl = mitk::SliceNavigationController::New("navigation");
47  ui.mainWid->InitRenderer();
48  ui.mainWid->GetRenderer()->SetMapperID(1);
50 
52 
53  factory->SetFileName( fileName );
54  factory->Update();
55  if (factory->GetNumberOfOutputs() > 1) {
56  fl_alert("WARNING: More than one image in file. Only showing first one.");
57  }
58  mitk::DataTreePreOrderIterator it(tree);
59  mitk::DataNode::Pointer node = factory->GetOutput( 0 );
60  assert(node.IsNotNull());
61  {
62  it.Add( node );
63  ui.mainWid->SetNode(node);
64  }
65  ui.mainWid->GetRenderer()->SetData(&it);
66  ui.mainWid->RequestUpdate();
67 
68  mitk::BoundingBox::Pointer bb = mitk::DataTree::ComputeVisibleBoundingBox(&it);
69 
71  geometry->Initialize();
72  geometry->SetBounds(bb->GetBounds());
73 
74  //tell the navigator the geometry to be sliced (with geometry a Geometry3D::ConstPointer)
75  sliceCtrl->SetInputWorldGeometry(geometry.GetPointer());
76  //tell the navigator in which direction it shall slice the data
77  sliceCtrl->SetViewDirection(mitk::SliceNavigationController::Axial);
78  //Connect one or more BaseRenderer to this navigator, i.e.: events sent
79  //by the navigator when stepping through the slices (e.g. by
80  //sliceCtrl->GetSlice()->Next()) will be received by the BaseRenderer
81  //(in this example only slice-changes, see also ConnectGeometryTimeEvent
82  //and ConnectGeometryEvents.)
83  sliceCtrl->ConnectGeometrySliceEvent(ui.mainWid->GetRenderer());
84  //create a world geometry and send the information to the connected renderer(s)
85  sliceCtrl->Update();
86  sliceCtrl->GetSlice()->SetPos(3);
87 
88  ui.sliceSlider->bounds(0,sliceCtrl->GetSlice()->GetSteps()-1);
89  ui.sliceSlider->precision(0);
90  ui.mainWid->RequestUpdate();
91  ui.mainWin->show(argc, argv);
92 
93  return Fl::run();
94 }
itk::SmartPointer< Self > Pointer
static Pointer New()
static Pointer New()
int main(int argc, char **argv)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.