diff --git a/Examples/Plugins/PluginList.cmake b/Examples/Plugins/PluginList.cmake index 4a4d4ec08e..4f595b8cec 100644 --- a/Examples/Plugins/PluginList.cmake +++ b/Examples/Plugins/PluginList.cmake @@ -1,17 +1,18 @@ # Plug-ins must be ordered according to their dependencies set(MITK_EXAMPLE_PLUGINS org.mitk.example.gui.minimalapplication:ON org.mitk.example.gui.customviewer:ON org.mitk.example.gui.customviewer.views:ON org.mitk.example.gui.multipleperspectives:ON org.mitk.example.gui.selectionserviceqt:ON org.mitk.example.gui.selectionservicemitk:ON org.mitk.example.gui.selectionservicemitk.views:ON org.mitk.example.gui.extensionpointdefinition:ON org.mitk.example.gui.extensionpointcontribution:ON org.mitk.example.gui.regiongrowing:ON org.mitk.example.gui.pcaexample:ON org.mitk.example.gui.imaging:ON + org.mitk.example.gui.forms:ON ) diff --git a/Examples/Plugins/org.mitk.example.gui.forms/CMakeLists.txt b/Examples/Plugins/org.mitk.example.gui.forms/CMakeLists.txt new file mode 100644 index 0000000000..1f1cbb8764 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/CMakeLists.txt @@ -0,0 +1,8 @@ +project(org_mitk_example_gui_forms) + +mitk_create_plugin( + EXPORT_DIRECTIVE FORMS_EXPORT + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDS MitkFormsUI + NO_INSTALL +) diff --git a/Examples/Plugins/org.mitk.example.gui.forms/files.cmake b/Examples/Plugins/org.mitk.example.gui.forms/files.cmake new file mode 100644 index 0000000000..69d97f7b42 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/files.cmake @@ -0,0 +1,18 @@ +set(CPP_FILES + src/internal/mitkPluginActivator.cpp + src/internal/QmitkFormsExampleView.cpp +) + +set(MOC_H_FILES + src/internal/mitkPluginActivator.h + src/internal/QmitkFormsExampleView.h +) + +set(CACHED_RESOURCE_FILES + resources/FormsIcon.svg + plugin.xml +) + +set(QRC_FILES + resources/FormsExample.qrc +) diff --git a/Examples/Plugins/org.mitk.example.gui.forms/manifest_headers.cmake b/Examples/Plugins/org.mitk.example.gui.forms/manifest_headers.cmake new file mode 100644 index 0000000000..59fbd0ee21 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Forms Example") +set(Plugin-Version "0.1") +set(Plugin-Vendor "German Cancer Research Center (DKFZ)") +set(Plugin-ContactAddress "https://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Examples/Plugins/org.mitk.example.gui.forms/plugin.xml b/Examples/Plugins/org.mitk.example.gui.forms/plugin.xml new file mode 100644 index 0000000000..f5fc563d96 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/plugin.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/Examples/Plugins/org.mitk.example.gui.forms/resources/ExampleForm.json b/Examples/Plugins/org.mitk.example.gui.forms/resources/ExampleForm.json new file mode 100644 index 0000000000..7ac5cd0e12 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/resources/ExampleForm.json @@ -0,0 +1,67 @@ +{ + "FileFormat": "MITK Form", + "Version": 1, + "Sections": [ + { + "Title": "Example Form", + "Description": "This form was deserialized from a JSSON file. Feel free to complete and submit it, resp. save its responses to a new or existing comma-separated value file.", + "Questions": [ + { + "Text": "Is this is a multiple choice question?", + "Required": true, + "Type": "Multiple choice", + "Options": [ + "Yes, it is.", + "No, it isn't. Wait... it actually is." + ], + "Other": true + }, + { + "Text": "Is this a checkboxes question?", + "Type": "Checkboxes", + "Options": [ + "Yes, it is.", + "It is indeed.", + "Yep, I'm sure." + ], + "Other": true + }, + { + "Text": "Do you agree that this is a linear scale question?", + "Required": true, + "Type": "Linear scale", + "Range": [ + 1, + 4 + ], + "Labels": [ + "Agree", + "Agree even more" + ] + }, + { + "Text": "Is this a short-answer question?", + "Type": "Short answer" + } + ] + }, + { + "Title": "Second section", + "Description": "Welcome to the second and last section of this form.", + "Questions": [ + { + "Text": "Is this a dropdown question?", + "Type": "Drop-down", + "Options": [ + "Yes, it is.", + "I'm not sure (yes)." + ] + }, + { + "Text": "Is this a paragraph question?", + "Type": "Paragraph" + } + ] + } + ] +} diff --git a/Examples/Plugins/org.mitk.example.gui.forms/resources/FormsExample.qrc b/Examples/Plugins/org.mitk.example.gui.forms/resources/FormsExample.qrc new file mode 100644 index 0000000000..9b4072c7ea --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/resources/FormsExample.qrc @@ -0,0 +1,6 @@ + + + FormsIcon.svg + ExampleForm.json + + diff --git a/Examples/Plugins/org.mitk.example.gui.forms/resources/FormsIcon.svg b/Examples/Plugins/org.mitk.example.gui.forms/resources/FormsIcon.svg new file mode 100644 index 0000000000..2ba2d6773e --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/resources/FormsIcon.svg @@ -0,0 +1,68 @@ + + + + diff --git a/Examples/Plugins/org.mitk.example.gui.forms/src/internal/QmitkFormsExampleView.cpp b/Examples/Plugins/org.mitk.example.gui.forms/src/internal/QmitkFormsExampleView.cpp new file mode 100644 index 0000000000..4fc85f4f92 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/src/internal/QmitkFormsExampleView.cpp @@ -0,0 +1,56 @@ +/*============================================================================ + +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 "QmitkFormsExampleView.h" +#include + +#include + +#include +#include +#include + +const std::string QmitkFormsExampleView::VIEW_ID = "org.mitk.views.example.forms"; + +namespace +{ + QString ReadFileAsString(const QString& path) + { + QFile file(path); + + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + mitkThrow() << "Could not open file \"" << path << "\"!"; + + QTextStream stream(&file); + return stream.readAll(); + } +} + +QmitkFormsExampleView::QmitkFormsExampleView() + : m_Form(nlohmann::json::parse(ReadFileAsString(":/FormsExample/ExampleForm.json").toStdString())) +{ +} + +QmitkFormsExampleView::~QmitkFormsExampleView() +{ +} + +void QmitkFormsExampleView::CreateQtPartControl(QWidget* parent) +{ + auto layout = new QVBoxLayout(parent); + layout->addWidget(new QmitkForm(m_Form)); + layout->addStretch(); +} + +void QmitkFormsExampleView::SetFocus() +{ +} diff --git a/Examples/Plugins/org.mitk.example.gui.forms/src/internal/QmitkFormsExampleView.h b/Examples/Plugins/org.mitk.example.gui.forms/src/internal/QmitkFormsExampleView.h new file mode 100644 index 0000000000..f541a1fb75 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/src/internal/QmitkFormsExampleView.h @@ -0,0 +1,36 @@ +/*============================================================================ + +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 QmitkFormsExampleView_h +#define QmitkFormsExampleView_h + +#include +#include + +class QmitkFormsExampleView : public QmitkAbstractView +{ + Q_OBJECT + +public: + static const std::string VIEW_ID; + + QmitkFormsExampleView(); + ~QmitkFormsExampleView() override; + + void CreateQtPartControl(QWidget* parent) override; + void SetFocus() override; + +private: + mitk::Forms::Form m_Form; +}; + +#endif diff --git a/Examples/Plugins/org.mitk.example.gui.forms/src/internal/mitkPluginActivator.cpp b/Examples/Plugins/org.mitk.example.gui.forms/src/internal/mitkPluginActivator.cpp new file mode 100644 index 0000000000..428d756dbd --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/src/internal/mitkPluginActivator.cpp @@ -0,0 +1,23 @@ +/*============================================================================ + +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 "mitkPluginActivator.h" +#include "QmitkFormsExampleView.h" + +void mitk::mitkPluginActivator::start(ctkPluginContext* context) +{ + BERRY_REGISTER_EXTENSION_CLASS(QmitkFormsExampleView, context) +} + +void mitk::mitkPluginActivator::stop(ctkPluginContext*) +{ +} diff --git a/Examples/Plugins/org.mitk.example.gui.forms/src/internal/mitkPluginActivator.h b/Examples/Plugins/org.mitk.example.gui.forms/src/internal/mitkPluginActivator.h new file mode 100644 index 0000000000..72d1f42520 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.forms/src/internal/mitkPluginActivator.h @@ -0,0 +1,32 @@ +/*============================================================================ + +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 mitkPluginActivator_h +#define mitkPluginActivator_h + +#include + +namespace mitk +{ + class mitkPluginActivator : public QObject, public ctkPluginActivator + { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org_mitk_gui_example_forms") + Q_INTERFACES(ctkPluginActivator) + + public: + void start(ctkPluginContext* context) override; + void stop(ctkPluginContext* context) override; + }; +} + +#endif