diff --git a/Plugins/org.mitk.gui.qt.ext/files.cmake b/Plugins/org.mitk.gui.qt.ext/files.cmake
index d00f357e6c..b4b7d9d037 100644
--- a/Plugins/org.mitk.gui.qt.ext/files.cmake
+++ b/Plugins/org.mitk.gui.qt.ext/files.cmake
@@ -1,61 +1,58 @@
set(SRC_CPP_FILES
QmitkExtActionBarAdvisor.cpp
QmitkExtWorkbenchWindowAdvisor.cpp
QmitkExtFileSaveProjectAction.cpp
QmitkOpenDicomEditorAction.cpp
QmitkOpenMxNMultiWidgetEditorAction.cpp
QmitkOpenStdMultiWidgetEditorAction.cpp
)
set(INTERNAL_CPP_FILES
QmitkAboutHandler.cpp
QmitkAppInstancesPreferencePage.cpp
- QmitkExternalProgramsPreferencePage.cpp
QmitkCommonExtPlugin.cpp
QmitkModuleView.cpp
)
set(UI_FILES
src/internal/QmitkAppInstancesPreferencePage.ui
- src/internal/QmitkExternalProgramsPreferencePage.ui
)
set(MOC_H_FILES
src/QmitkExtFileSaveProjectAction.h
src/QmitkExtWorkbenchWindowAdvisor.h
src/internal/QmitkAboutHandler.h
src/internal/QmitkAppInstancesPreferencePage.h
- src/internal/QmitkExternalProgramsPreferencePage.h
src/internal/QmitkCommonExtPlugin.h
src/internal/QmitkExtWorkbenchWindowAdvisorHack.h
src/internal/QmitkModuleView.h
src/QmitkOpenDicomEditorAction.h
src/QmitkOpenMxNMultiWidgetEditorAction.h
src/QmitkOpenStdMultiWidgetEditorAction.h
)
set(CACHED_RESOURCE_FILES
# list of resource files which can be used by the plug-in
# system without loading the plug-ins shared library,
# for example the icon used in the menu and tabs for the
# plug-in views in the workbench
plugin.xml
resources/ModuleView.png
)
set(QRC_FILES
# uncomment the following line if you want to use Qt resources
resources/org_mitk_gui_qt_ext.qrc
resources/org_mitk_icons.qrc
)
set(CPP_FILES )
foreach(file ${SRC_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/${file})
endforeach(file ${SRC_CPP_FILES})
foreach(file ${INTERNAL_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/internal/${file})
endforeach(file ${INTERNAL_CPP_FILES})
diff --git a/Plugins/org.mitk.gui.qt.ext/plugin.xml b/Plugins/org.mitk.gui.qt.ext/plugin.xml
index 2c87bf9f64..293a24f24a 100644
--- a/Plugins/org.mitk.gui.qt.ext/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.ext/plugin.xml
@@ -1,37 +1,32 @@
-
-
-
-
diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp
index 99394e3e56..390dfdf75f 100644
--- a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp
+++ b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp
@@ -1,238 +1,236 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include "QmitkCommonExtPlugin.h"
#include
#include "QmitkAboutHandler.h"
#include "QmitkAppInstancesPreferencePage.h"
-#include "QmitkExternalProgramsPreferencePage.h"
#include "QmitkModuleView.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
US_INITIALIZE_MODULE
ctkPluginContext* QmitkCommonExtPlugin::_context = nullptr;
void QmitkCommonExtPlugin::start(ctkPluginContext* context)
{
this->_context = context;
QtWidgetsExtRegisterClasses();
BERRY_REGISTER_EXTENSION_CLASS(QmitkAboutHandler, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkAppInstancesPreferencePage, context)
- BERRY_REGISTER_EXTENSION_CLASS(QmitkExternalProgramsPreferencePage, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkModuleView, context)
if (qApp->metaObject()->indexOfSignal("messageReceived(QByteArray)") > -1)
{
connect(qApp, SIGNAL(messageReceived(QByteArray)), this, SLOT(handleIPCMessage(QByteArray)));
}
// This is a potentially long running operation.
loadDataFromDisk(berry::Platform::GetApplicationArgs(), true);
}
void QmitkCommonExtPlugin::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
this->_context = nullptr;
}
ctkPluginContext* QmitkCommonExtPlugin::getContext()
{
return _context;
}
void QmitkCommonExtPlugin::loadDataFromDisk(const QStringList &arguments, bool globalReinit)
{
if (!arguments.empty())
{
ctkServiceReference serviceRef = _context->getServiceReference();
if (serviceRef)
{
mitk::IDataStorageService* dataStorageService = _context->getService(serviceRef);
mitk::DataStorage::Pointer dataStorage = dataStorageService->GetDefaultDataStorage()->GetDataStorage();
int argumentsAdded = 0;
for (int i = 0; i < arguments.size(); ++i)
{
if (arguments[i].right(5) == ".mitk")
{
mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New();
bool clearDataStorageFirst(false);
mitk::ProgressBar::GetInstance()->AddStepsToDo(2);
dataStorage = sceneIO->LoadScene( arguments[i].toLocal8Bit().constData(), dataStorage, clearDataStorageFirst );
mitk::ProgressBar::GetInstance()->Progress(2);
argumentsAdded++;
}
else if (arguments[i].right(15) == ".mitksceneindex")
{
mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New();
bool clearDataStorageFirst(false);
mitk::ProgressBar::GetInstance()->AddStepsToDo(2);
dataStorage = sceneIO->LoadSceneUnzipped(arguments[i].toLocal8Bit().constData(), dataStorage, clearDataStorageFirst);
mitk::ProgressBar::GetInstance()->Progress(2);
argumentsAdded++;
}
else
{
try
{
const std::string path(arguments[i].toStdString());
auto addedNodes = mitk::IOUtil::Load(path, *dataStorage);
for (const auto& node : *addedNodes )
{
node->SetIntProperty("layer", argumentsAdded);
}
argumentsAdded++;
}
catch(...)
{
MITK_WARN << "Failed to load command line argument: " << arguments[i].toStdString();
}
}
} // end for each command line argument
if (argumentsAdded > 0 && globalReinit)
{
// calculate bounding geometry
mitk::RenderingManager::GetInstance()->InitializeViews(dataStorage->ComputeBoundingGeometry3D());
}
}
else
{
MITK_ERROR << "A service reference for mitk::IDataStorageService does not exist";
}
}
}
void QmitkCommonExtPlugin::startNewInstance(const QStringList &args, const QStringList& files)
{
QStringList newArgs(args);
#ifdef Q_OS_UNIX
newArgs << QString("--") + mitk::BaseApplication::ARG_NEWINSTANCE;
#else
newArgs << QString("/") + mitk::BaseApplication::ARG_NEWINSTANCE;
#endif
newArgs << files;
QProcess::startDetached(qApp->applicationFilePath(), newArgs);
}
void QmitkCommonExtPlugin::handleIPCMessage(const QByteArray& msg)
{
QDataStream ds(msg);
QString msgType;
ds >> msgType;
// we only handle messages containing command line arguments
if (msgType != "$cmdLineArgs") return;
// activate the current workbench window
berry::IWorkbenchWindow::Pointer window =
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow();
QMainWindow* mainWindow =
static_cast (window->GetShell()->GetControl());
mainWindow->setWindowState(mainWindow->windowState() & ~Qt::WindowMinimized);
mainWindow->raise();
mainWindow->activateWindow();
// Get the preferences for the instantiation behavior
auto* prefService = mitk::CoreServices::GetPreferencesService();
auto* prefs = prefService->GetSystemPreferences()->Node("/General");
bool newInstanceAlways = prefs->GetBool("newInstance.always", false);
bool newInstanceScene = prefs->GetBool("newInstance.scene", true);
QStringList args;
ds >> args;
QStringList fileArgs;
QStringList sceneArgs;
foreach (QString arg, args)
{
if (arg.endsWith(".mitk"))
{
sceneArgs << arg;
}
else
{
fileArgs << arg;
}
}
if (newInstanceAlways)
{
if (newInstanceScene)
{
startNewInstance(args, fileArgs);
foreach(QString sceneFile, sceneArgs)
{
startNewInstance(args, QStringList(sceneFile));
}
}
else
{
fileArgs.append(sceneArgs);
startNewInstance(args, fileArgs);
}
}
else
{
loadDataFromDisk(fileArgs, false);
if (newInstanceScene)
{
foreach(QString sceneFile, sceneArgs)
{
startNewInstance(args, QStringList(sceneFile));
}
}
else
{
loadDataFromDisk(sceneArgs, false);
}
}
}
diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.cpp b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.cpp
deleted file mode 100644
index c9d0fb7efa..0000000000
--- a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*============================================================================
-
-The Medical Imaging Interaction Toolkit (MITK)
-
-Copyright (c) German Cancer Research Center (DKFZ)
-All rights reserved.
-
-Use of this source code is governed by a 3-clause BSD license that can be
-found in the LICENSE file.
-
-============================================================================*/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "QmitkExternalProgramsPreferencePage.h"
-
-namespace
-{
- mitk::IPreferences* GetPreferences()
- {
- auto* preferencesService = mitk::CoreServices::GetPreferencesService();
- return preferencesService->GetSystemPreferences()->Node("org.mitk.gui.qt.ext.externalprograms");
- }
-}
-
-QmitkExternalProgramsPreferencePage::QmitkExternalProgramsPreferencePage()
- : m_Ui(new Ui::QmitkExternalProgramsPreferencePage),
- m_Control(nullptr),
- m_GnuplotProcess(nullptr)
-{
-}
-
-QmitkExternalProgramsPreferencePage::~QmitkExternalProgramsPreferencePage()
-{
-}
-
-void QmitkExternalProgramsPreferencePage::CreateQtControl(QWidget* parent)
-{
- m_Control = new QWidget(parent);
- m_GnuplotProcess = new QProcess(m_Control);
-
- m_Ui->setupUi(m_Control);
-
- connect(m_GnuplotProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(OnGnuplotProcessError(QProcess::ProcessError)));
- connect(m_GnuplotProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(OnGnuplotProcessFinished(int, QProcess::ExitStatus)));
- connect(m_Ui->gnuplotButton, SIGNAL(clicked()), this, SLOT(OnGnuplotButtonClicked()));
-
- this->Update();
-}
-
-void QmitkExternalProgramsPreferencePage::OnGnuplotButtonClicked()
-{
- QString filter = "gnuplot executable ";
-
-#if defined(WIN32)
- filter += "(gnuplot.exe)";
-#else
- filter += "(gnuplot)";
-#endif
-
- QString gnuplotPath = QFileDialog::getOpenFileName(m_Control, "Gnuplot", "", filter);
-
- if (!gnuplotPath.isEmpty())
- {
- m_GnuplotPath = gnuplotPath;
- m_GnuplotProcess->start(gnuplotPath, QStringList() << "--version", QProcess::ReadOnly);
- }
-}
-
-void QmitkExternalProgramsPreferencePage::OnGnuplotProcessError(QProcess::ProcessError)
-{
- m_GnuplotPath.clear();
- m_Ui->gnuplotLineEdit->clear();
-}
-
-void QmitkExternalProgramsPreferencePage::OnGnuplotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
-{
- if (exitStatus == QProcess::NormalExit && exitCode == 0)
- {
- QString output = QTextCodec::codecForName("UTF-8")->toUnicode(m_GnuplotProcess->readAllStandardOutput());
-
- if (output.startsWith("gnuplot"))
- {
- m_Ui->gnuplotLineEdit->setText(m_GnuplotPath);
- return;
- }
- }
-
- m_GnuplotPath.clear();
- m_Ui->gnuplotLineEdit->clear();
-}
-
-QWidget* QmitkExternalProgramsPreferencePage::GetQtControl() const
-{
- return m_Control;
-}
-
-void QmitkExternalProgramsPreferencePage::Init(berry::IWorkbench::Pointer)
-{
-}
-
-void QmitkExternalProgramsPreferencePage::PerformCancel()
-{
-}
-
-bool QmitkExternalProgramsPreferencePage::PerformOk()
-{
- auto* prefs = GetPreferences();
-
- prefs->Put("gnuplot", m_GnuplotPath.toStdString());
-
- return true;
-}
-
-void QmitkExternalProgramsPreferencePage::Update()
-{
- auto* prefs = GetPreferences();
-
- m_GnuplotPath = QString::fromStdString(prefs->Get("gnuplot", ""));
-
- if (!m_GnuplotPath.isEmpty())
- m_GnuplotProcess->start(m_GnuplotPath, QStringList() << "--version", QProcess::ReadOnly);
-}
diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.h b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.h
deleted file mode 100644
index 2457e3b42f..0000000000
--- a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*============================================================================
-
-The Medical Imaging Interaction Toolkit (MITK)
-
-Copyright (c) German Cancer Research Center (DKFZ)
-All rights reserved.
-
-Use of this source code is governed by a 3-clause BSD license that can be
-found in the LICENSE file.
-
-============================================================================*/
-
-#ifndef QmitkExternalProgramsPreferencePage_h
-#define QmitkExternalProgramsPreferencePage_h
-
-#include
-#include
-#include
-
-namespace Ui
-{
- class QmitkExternalProgramsPreferencePage;
-}
-
-class QmitkExternalProgramsPreferencePage : public QObject, public berry::IQtPreferencePage
-{
- Q_OBJECT
- Q_INTERFACES(berry::IPreferencePage)
-
-public:
- QmitkExternalProgramsPreferencePage();
- ~QmitkExternalProgramsPreferencePage() override;
-
- void CreateQtControl(QWidget* parent) override;
- QWidget* GetQtControl() const override;
- void Init(berry::IWorkbench::Pointer) override;
- void PerformCancel() override;
- bool PerformOk() override;
- void Update() override;
-
-private slots:
- void OnGnuplotButtonClicked();
- void OnGnuplotProcessError(QProcess::ProcessError error);
- void OnGnuplotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
-
-private:
- QScopedPointer m_Ui;
- QWidget* m_Control;
-
- QProcess* m_GnuplotProcess;
- QString m_GnuplotPath;
-};
-
-#endif
diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.ui b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.ui
deleted file mode 100644
index 69f491a9e4..0000000000
--- a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.ui
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
- QmitkExternalProgramsPreferencePage
-
-
-
- 0
- 0
- 400
- 152
-
-
-
- External Programs
-
-
- -
-
-
- gnuplot:
-
-
- Qt::PlainText
-
-
- gnuplotButton
-
-
-
- -
-
-
-
-
-
- true
-
-
-
- -
-
-
- ...
-
-
-
-
-
-
-
-
-
-