Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkOpenDicomEditorAction.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 
18 
19 #include <QFileDialog>
20 #include <QFileInfo>
21 
22 #include "mitkCoreObjectFactory.h"
23 #include "mitkSceneIO.h"
24 #include "mitkProgressBar.h"
25 
27 #include <berryIEditorPart.h>
28 #include <berryIWorkbenchPage.h>
30 #include <berryIWorkbench.h>
31 #include <berryPlatform.h>
32 #include <berryFileEditorInput.h>
33 
34 #include "mitkProperties.h"
35 #include "mitkNodePredicateData.h"
36 #include "mitkNodePredicateNot.h"
38 
39 
40 //#include <QmitkStdMultiWidgetEditor.h>
41 
43 : QAction(0)
44 {
45  this->init(window);
46 }
47 
49 : QAction(0)
50 {
51  this->setIcon(icon);
52 
53  this->init(window);
54 }
55 
56 void QmitkOpenDicomEditorAction::init(berry::IWorkbenchWindow::Pointer window)
57 {
58  m_Window = window;
59  this->setParent(static_cast<QWidget*>(m_Window->GetShell()->GetControl()));
60  this->setText("&DICOM");
61  this->setToolTip("Open dicom tool");
62 
64 
65  m_GeneralPreferencesNode = prefService->GetSystemPreferences()->Node("/General");
66 
67  this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run()));
68 }
69 
71 {
72 
73  // check if there is an open perspective, if not open the default perspective
74  if (m_Window->GetActivePage().IsNull())
75  {
76  QString defaultPerspId = m_Window->GetWorkbench()->GetPerspectiveRegistry()->GetDefaultPerspective();
77  m_Window->GetWorkbench()->ShowPerspective(defaultPerspId, m_Window);
78  }
79 
80  //mitk::DataStorageEditorInput::Pointer editorInput;
81  //mitk::DataStorage::Pointer dataStorage;
82  //QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor;
83  //berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->GetActiveEditor();
84 
85 
86 
87  //if (editor.Cast<QmitkStdMultiWidgetEditor>().IsNull())
88  //{
89  // editorInput = new mitk::DataStorageEditorInput();
90  // dataStorage = editorInput->GetDataStorageReference()->GetDataStorage();
91  //}
92  //else
93  //{
94  // multiWidgetEditor = editor.Cast<QmitkStdMultiWidgetEditor>();
95  // dataStorage = multiWidgetEditor->GetEditorInput().Cast<mitk::DataStorageEditorInput>()->GetDataStorageReference()->GetDataStorage();
96  //}
97 
98  //if (multiWidgetEditor.IsNull())
99  //{
100  // //berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID);
101  // multiWidgetEditor = editor.Cast<QmitkStdMultiWidgetEditor>();
102  //}
103  //else
104  //{
105  // multiWidgetEditor->GetStdMultiWidget()->RequestUpdate();
106  //}
107 
108  berry::IEditorInput::Pointer editorInput2(new berry::FileEditorInput(QString()));
109  m_Window->GetActivePage()->OpenEditor(editorInput2, "org.mitk.editors.dicomeditor");
110 }
111 
virtual SmartPointer< IPreferences > GetSystemPreferences()=0
QmitkOpenDicomEditorAction(berry::IWorkbenchWindow::Pointer window)
static IPreferencesService * GetPreferencesService()