diff --git a/sdk/applications/wizard/ActionSummaryWidget.cpp b/sdk/applications/wizard/ActionSummaryWidget.cpp index 55f43e1f656ac11c377305e868d25709b6a5b84c..9877332c8949fd4636ec08e9d67c20eb7e8aaa8b 100644 --- a/sdk/applications/wizard/ActionSummaryWidget.cpp +++ b/sdk/applications/wizard/ActionSummaryWidget.cpp @@ -48,8 +48,6 @@ void ActionSummaryWidget::previousButtonClicked() { emit previous(); } - - void ActionSummaryWidget::setSummary(QString name, QString description, QString component, QStringList parameters, QString family, QStringList tags) { QString text = defaultActionSummary; diff --git a/sdk/applications/wizard/CepCreateRecapState.cpp b/sdk/applications/wizard/CepCreateRecapState.cpp index 026b4b78f7229e16bf4a1fa7fa3334a37fe20767..33accfa585d0859a1c0df9f5daae6bf9da7611f9 100644 --- a/sdk/applications/wizard/CepCreateRecapState.cpp +++ b/sdk/applications/wizard/CepCreateRecapState.cpp @@ -49,6 +49,7 @@ void CepCreateRecapState::onEntry(QEvent* event) { if (cepCreateRecapWidget != nullptr) { updateCepDescription(cepCreateRecapWidget); updateActionExtensions(cepCreateRecapWidget); + updateViewerExtensions(cepCreateRecapWidget); updateComponentExtensions(cepCreateRecapWidget); updateCepLibraries(cepCreateRecapWidget); } @@ -71,6 +72,20 @@ void CepCreateRecapState::updateCepDescription(CepCreateRecapWidget* cepCreateRe cepCreateRecapWidget->setContactItself(cepContact); } + +void CepCreateRecapState::updateViewerExtensions(CepCreateRecapWidget* cepCreateRecapWidget) { + cepCreateRecapWidget->emptyExistingViewerExtensions(); + if (domCep->viewerExtensions().present()) { + cepcoreschema::ViewerExtensions cepViewerExtensions = domCep->viewerExtensions().get(); + cepcoreschema::ViewerExtensions::viewerExtension_iterator it; + for (it = cepViewerExtensions.viewerExtension().begin(); it != cepViewerExtensions.viewerExtension().end(); it++) { + cepcoreschema::ViewerExtension extension = (*it); + QString viewerExtensionName = extension.name().c_str(); + cepCreateRecapWidget->addViewerExtension(viewerExtensionName); + } + } +} + void CepCreateRecapState::updateActionExtensions(CepCreateRecapWidget* cepCreateRecapWidget) { cepCreateRecapWidget->emptyExistingActionExtensions(); if (domCep->actionExtensions().present()) { diff --git a/sdk/applications/wizard/CepCreateRecapState.h b/sdk/applications/wizard/CepCreateRecapState.h index 4ccd4b6eb987c37e940230002408f54349a50bc5..eb8fb20e8120f9b53b13cefa960a5f88e1b011d9 100644 --- a/sdk/applications/wizard/CepCreateRecapState.h +++ b/sdk/applications/wizard/CepCreateRecapState.h @@ -58,6 +58,7 @@ protected: private: void updateCepDescription(CepCreateRecapWidget* cepCreateRecapWidget); + void updateViewerExtensions(CepCreateRecapWidget * cepCreateRecapWidget); void updateActionExtensions(CepCreateRecapWidget* cepCreateRecapWidget); void updateComponentExtensions(CepCreateRecapWidget* cepCreateRecapWidget); void updateCepLibraries(CepCreateRecapWidget* cepCreateRecapWidget); diff --git a/sdk/applications/wizard/CepCreateRecapWidget.cpp b/sdk/applications/wizard/CepCreateRecapWidget.cpp index 68db0e728e36cc621e4ae97de6fb0cfce39af734..914487d9ce06ac0c553b2e2b4dd16c088a942673 100644 --- a/sdk/applications/wizard/CepCreateRecapWidget.cpp +++ b/sdk/applications/wizard/CepCreateRecapWidget.cpp @@ -36,6 +36,16 @@ static const QString defaultExistingActionExtensions = "\ \ "; +static const QString defaultExistingViewerExtensions = "\ +\ + \ + \ +

Created Viewer Extensions:

\ + \ + \ +"; + static const QString defaultExistingComponentExtensions = "\ \ \ @@ -62,6 +72,7 @@ CepCreateRecapWidget::CepCreateRecapWidget(QWidget* parent) : QWidget(parent) { ui.setupUi(this); createdLibrariesString = defaultExistingLibraries; createdActionsString = defaultExistingActionExtensions; + createdViewersString = defaultExistingViewerExtensions; createdComponentsString = defaultExistingComponentExtensions; } @@ -84,6 +95,11 @@ void CepCreateRecapWidget::setContactItself(QString contact) { void CepCreateRecapWidget::addActionExtensionClicked() { emit addActionExtension(); } + +void CepCreateRecapWidget::addViewerExtensionClicked() { + emit addViewerExtension(); +} + void CepCreateRecapWidget::addComponentExtensionClicked() { emit addComponentExtension(); } @@ -97,6 +113,21 @@ void CepCreateRecapWidget::emptyExistingActionExtensions() { ui.existingActionExtensions->setHtml(createdActionsString); } +void CepCreateRecapWidget::emptyExistingViewerExtensions() { + createdViewersString = defaultExistingViewerExtensions; + ui.existingViewerExtensions->setHtml(createdViewersString); +} + +void CepCreateRecapWidget::emptyExistingComponentExtensions() { + createdComponentsString = defaultExistingComponentExtensions; + ui.existingComponentExtensions->setHtml(createdComponentsString); +} + +void CepCreateRecapWidget::emptyExistingLibraries() { + createdLibrariesString = defaultExistingLibraries; + ui.existingLibrariesTextEdit->setHtml(createdLibrariesString); +} + void CepCreateRecapWidget::addActionExtension(QString actionExtensionName) { QString toBeInserted = "
  • " + actionExtensionName + "
  • \n"; int index = createdActionsString.lastIndexOf(""); @@ -105,9 +136,12 @@ void CepCreateRecapWidget::addActionExtension(QString actionExtensionName) { ui.existingActionExtensions->setHtml(createdActionsString); } -void CepCreateRecapWidget::emptyExistingComponentExtensions() { - createdComponentsString = defaultExistingComponentExtensions; - ui.existingComponentExtensions->setHtml(createdComponentsString); +void CepCreateRecapWidget::addViewerExtension(QString viewerExtensionName) { + QString toBeInserted = "
  • " + viewerExtensionName + "
  • \n"; + int index = createdViewersString.lastIndexOf(""); + + createdViewersString.insert(index, toBeInserted); + ui.existingViewerExtensions->setHtml(createdViewersString); } void CepCreateRecapWidget::addComponentExtension(QString componentExtensionName) { @@ -118,11 +152,6 @@ void CepCreateRecapWidget::addComponentExtension(QString componentExtensionName) ui.existingComponentExtensions->setHtml(createdComponentsString); } -void CepCreateRecapWidget::emptyExistingLibraries() { - createdLibrariesString = defaultExistingLibraries; - ui.existingLibrariesTextEdit->setHtml(createdLibrariesString); -} - void CepCreateRecapWidget::addLibrary(QString libraryNamme) { QString toBeInserted = "
  • " + libraryNamme + "
  • \n"; int index = createdLibrariesString.lastIndexOf(""); diff --git a/sdk/applications/wizard/CepCreateRecapWidget.h b/sdk/applications/wizard/CepCreateRecapWidget.h index 0cfbcd49123235adc4d010ed308097e72a8e0798..e55a27877bfe33ef8a2de4109f68cdf626252a30 100644 --- a/sdk/applications/wizard/CepCreateRecapWidget.h +++ b/sdk/applications/wizard/CepCreateRecapWidget.h @@ -53,17 +53,19 @@ public: void setContactItself(QString contact); void emptyExistingActionExtensions(); - void addActionExtension(QString actionExtensionName); + void emptyExistingViewerExtensions(); + void emptyExistingComponentExtensions(); + void emptyExistingLibraries(); - void emptyExistingComponentExtensions(); + void addActionExtension(QString actionExtensionName); + void addViewerExtension(QString viewerExtensionName); void addComponentExtension(QString componentExtensionName); - - void emptyExistingLibraries(); void addLibrary(QString libraryNamme); public slots: virtual void nextButtonClicked(); virtual void addActionExtensionClicked(); + virtual void addViewerExtensionClicked(); virtual void addComponentExtensionClicked(); virtual void addLibrariesClicked(); @@ -71,6 +73,7 @@ signals: void next(); void addLibrary(); void addActionExtension(); + void addViewerExtension(); void addComponentExtension(); private: @@ -79,6 +82,7 @@ private: QString createdLibrariesString; QString createdActionsString; + QString createdViewersString; QString createdComponentsString; }; #endif diff --git a/sdk/applications/wizard/CepCreateRecapWidget.ui b/sdk/applications/wizard/CepCreateRecapWidget.ui index ff310b4326ce0a43e9703ed491397b32e7742b43..43e7b2a2691302bd3affff6d8a67fb0c08fcc287 100644 --- a/sdk/applications/wizard/CepCreateRecapWidget.ui +++ b/sdk/applications/wizard/CepCreateRecapWidget.ui @@ -187,6 +187,33 @@ + + + + + + + + 0 + 32 + + + + + 64 + 64 + + + + + + + + :/resources/edit_add.png:/resources/edit_add.png + + + + @@ -219,6 +246,38 @@ + + + + + + + true + + + + 64 + 128 + + + + + 128 + 128 + + + + + + + :/resources/viewer.png + + + true + + + + @@ -297,6 +356,13 @@ <html><head/><body><p align="center"><span style=" font-style:italic;">Add An Action Extension</span></p></body></html> + + + + + <html><head/><body><p align="center"><span style=" font-style:italic;">Add An Viewer Extension</span></p></body></html> + + @@ -410,6 +476,19 @@ + + + + + 0 + 0 + + + + true + + + @@ -588,10 +667,27 @@ + + addViewerPushButton + clicked() + CepCreateRecapWidget + addViewerExtensionClicked() + + + 604 + 466 + + + 581 + 540 + + + nextButtonClicked() addActionExtensionClicked() + addViewerExtensionClicked() addComponentExtensionClicked() addLibrariesClicked() diff --git a/sdk/applications/wizard/DefaultGUIText.h b/sdk/applications/wizard/DefaultGUIText.h index ef40d5517878d3d249face16f26dd827e599dfcc..adb99f2b0726fbc7db8707122608dd4ae6884b2c 100644 --- a/sdk/applications/wizard/DefaultGUIText.h +++ b/sdk/applications/wizard/DefaultGUIText.h @@ -110,9 +110,28 @@ static const QString defaultActionExtensionExplanation = "\ \ "; +/* ------------------- Action Extension Description Widget ------------------ */ +static const QString defaultViewerExtensionExplanation = "\ +\ + \ + \ +

    \ + An Viewer Extension manages one or a set of actions targeting the same objective.
    \ + There is one directory for each Viewer Extension.
    \ + Each Viewer Extension results in one dynamic library (dll, so or dylib).\ +

    \ +

    Please fill-in the information requested for creating of an Viewer Extension.

    \ +

    The Viewers composing this Viewer Extension will be added in the next forms.

    \ + \ +\ +"; + static const QString defaultActionExtensionName = "Example Of An Action Extension"; static const QString defaultActionExtensionDescription = "This extension description is automatically generated in order to show new users how to easily write an extension with one or several Action(s)."; +static const QString defaultViewerExtensionName = "Example Of An Viewer Extension"; +static const QString defaultViewerExtensionDescription = "This extension description is automatically generated in order to show new users how to easily write an extension with one or several Viewer(s)."; + /* ------------------- Component Extension Description Widget ------------------ */ static const QString defaultComponentExtensionExplanation = "\ \ @@ -145,6 +164,15 @@ static const QString defaultRealActionName = "Please provide a real na static const QString defaultRealActionDescription = "Please provide a real description for your action,\nA real description should explain the goal and tell a little bit about the method of your action (for instance, you can reference a/your paper here).\n"; static const QString defaultActionNameAndExtension = "Please provide a name that is different from the name of the Action Extension.\n"; +/* ------------------------ Viewer Description Widget ----------------------- */ + +static const QString defaultViewerName = "Example Of An Viewer"; +static const QString defaultViewerDescription = "This description is automatically generated in order to show new users how to easily write an Viewer."; + +static const QString defaultRealViewerName = "Please provide a real name for your viewer,\nA real action name should express what your viewer is about.\n"; +static const QString defaultRealViewerDescription = "Please provide a real description for your viewer,\nA real description should explain the goal and tell a little bit about the method of your viewer (for instance, you can reference a/your paper here).\n"; +static const QString defaultViewerNameAndExtension = "Please provide a name that is different from the name of the Viewer Extension.\n"; + /* ------------------------ Component Description Widget ----------------------- */ static const QString defaultComponentName = "Example Of A Component"; @@ -174,6 +202,17 @@ static const QString defaultCreatedActionsString = "\ \ "; +/* ----------------------- Actions Creation Widget --------------------------- */ +static const QString defaultCreatedViewersString = "\ +\ +\ +\ +

    Created Viewer(s):

    \ +\ +\ +"; + /* ----------------------- Components Creation Widget --------------------------- */ static const QString defaultCreatedComponentsString = "\ \ @@ -217,6 +256,25 @@ static const QString defaultActionSummary = "\ "; +/* ----------------------- Viewer Symmary --------------------------- */ +static const QString defaultViewerSummary = "\ +\ + \ +\ +

    Summary

    \ +

    You are about to add the following Viewer

    \ +\ +
    \ +

    If you want to modify some elements of your Viewer, click on Previous.

    \ +

    If you want to cancel the creation of this Viewer, click on Cancel.

    \ +

    Clicking on Next will bring you back to the Viewer Extension page.

    \ +\ +"; + + /* ----------------------- Component Symmary --------------------------- */ static const QString defaultComponentSummary = "\ \ diff --git a/sdk/applications/wizard/ExtensionSummaryState.cpp b/sdk/applications/wizard/ExtensionSummaryState.cpp index 35951b11ad8dafc9a8523e10f687f623bb4b667f..a6868829cc4635426c7c14654f707bde0f9357f2 100644 --- a/sdk/applications/wizard/ExtensionSummaryState.cpp +++ b/sdk/applications/wizard/ExtensionSummaryState.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include ExtensionSummaryState::ExtensionSummaryState(QString name, ExtensionSummaryWidget* widget, QString type, WizardMainWindow* mainWindow, QState* parent) @@ -44,12 +46,14 @@ ExtensionSummaryState::ExtensionSummaryState(QString name, ExtensionSummaryWidge this->type = type; this->domActionExtension = nullptr; this->domComponentExtension = nullptr; + this->domViewerExtension = nullptr; } void ExtensionSummaryState::setActionExtension(cepcoreschema::ActionExtension* domActionExtension) { if (this->type == "Action") { this->domActionExtension = domActionExtension; this->domComponentExtension = nullptr; + this->domViewerExtension = nullptr; } } @@ -57,10 +61,18 @@ void ExtensionSummaryState::setComponentExtension(cepcoreschema::ComponentExtens if (this->type == "Component") { this->domActionExtension = nullptr; this->domComponentExtension = domComponentExtension; + this->domViewerExtension = nullptr; } } +void ExtensionSummaryState::setViewerExtension(cepcoreschema::ViewerExtension* domViewerExtension) { + if (this->type == "Viewer") { + this->domActionExtension = nullptr; + this->domComponentExtension = nullptr; + this->domViewerExtension = domViewerExtension; + } +} void ExtensionSummaryState::onEntry(QEvent* event) { WizardState::onEntry(event); @@ -119,6 +131,27 @@ void ExtensionSummaryState::onEntry(QEvent* event) { extensionSummaryWidget->setSummary(name, description, elements, dependencies); } + else if ((type == "Viewer") && (domViewerExtension != nullptr)) { + extensionSummaryWidget->setElement("Viewer"); + QString name = domViewerExtension->name().c_str(); + QString description = domViewerExtension->description().c_str(); + + QString viewerName = domViewerExtension->viewer().name().c_str(); + elements << viewerName; + + if (domViewerExtension->dependencies().present()) { + cepcoreschema::Dependencies deps = domViewerExtension->dependencies().get(); + cepcoreschema::Dependencies::dependency_iterator it; + for (it = deps.dependency().begin(); it != deps.dependency().end(); it++) { + cepcoreschema::Dependency& dep = (*it); + QString dependency = dep.name().c_str(); + dependencies << dependency; + } + } + + extensionSummaryWidget->setSummary(name, description, elements, dependencies); + } + } } diff --git a/sdk/applications/wizard/ExtensionSummaryState.h b/sdk/applications/wizard/ExtensionSummaryState.h index 5818973d3411a6ab92142f2ecca9ced99ca22ba5..bb2820b31a76533c025379903117ec2f9d495f30 100644 --- a/sdk/applications/wizard/ExtensionSummaryState.h +++ b/sdk/applications/wizard/ExtensionSummaryState.h @@ -34,6 +34,7 @@ class ExtensionSummaryWidget; namespace cepcoreschema { class ActionExtension; class ComponentExtension; +class ViewerExtension; } /** @@ -56,6 +57,7 @@ public: void setActionExtension(cepcoreschema::ActionExtension* domActionExtension); void setComponentExtension(cepcoreschema::ComponentExtension* domComponentExtension); + void setViewerExtension(cepcoreschema::ViewerExtension * domViewerExtension); protected: void onEntry(QEvent* event) override; @@ -65,6 +67,7 @@ protected: cepcoreschema::ActionExtension* domActionExtension; cepcoreschema::ComponentExtension* domComponentExtension; + cepcoreschema::ViewerExtension* domViewerExtension; }; #endif diff --git a/sdk/applications/wizard/GeneratingCEPState.cpp b/sdk/applications/wizard/GeneratingCEPState.cpp index 53578b2ac6de0ca1a730858698d3df332e31d7ac..741596b8ab0d2379df9c34fd7ce6beedb06b4f30 100644 --- a/sdk/applications/wizard/GeneratingCEPState.cpp +++ b/sdk/applications/wizard/GeneratingCEPState.cpp @@ -59,6 +59,8 @@ void GeneratingCEPState::onEntry(QEvent* event) { QString cepName = domCep->name().c_str(); std::cout << "cepName: " << cepName.toStdString() << std::endl; + std::cout << domCep->copyright().present() << std::endl; + cepcoreschema::Cep aCep(*domCep); std::unique_ptr domCepPtr(domCep); diff --git a/sdk/applications/wizard/ViewerCreationState.cpp b/sdk/applications/wizard/ViewerCreationState.cpp new file mode 100644 index 0000000000000000000000000000000000000000..09e9aafe0a9c343d5d5937583ba42be3da142647 --- /dev/null +++ b/sdk/applications/wizard/ViewerCreationState.cpp @@ -0,0 +1,108 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewerCreationState.h" +#include "WizardMainWindow.h" +#include "ViewerExtensionCreationState.h" + +#include "ViewerDescriptionWidget.h" +#include "ViewerDescriptionState.h" +#include "ViewerSummaryWidget.h" +#include "ViewerSummaryState.h" + +#include +#include +#include +#include + +ViewerCreationState::ViewerCreationState(QString name, WizardMainWindow* mainWindow, cepcoreschema::Cep* domCep, ViewerExtensionCreationState* parent) : QState(parent) { + this->name = name; + this->cancelled = false; + this->domViewer = nullptr; + + this->domViewerExtension = nullptr; + this->domCep = domCep; + + createSubStates(mainWindow); +} + +void ViewerCreationState::resetDomViewerExtension(cepcoreschema::ViewerExtension* domViewerExtension) { + this->domViewerExtension = domViewerExtension; +} + +void ViewerCreationState::onEntry(QEvent* event) { + this->cancelled = false; + cepcoreschema::ViewerType type(cepcoreschema::ViewerType::EMBEDDED); + + if (domViewer != nullptr) { + delete domViewer; + domViewer = nullptr; + } + + domViewer = new cepcoreschema::Viewer("A Viewer", "A viewer description", type); + viewerDescriptionState->resetDomViewer(domViewer, domViewerExtension); + viewerSummaryState->resetViewer(domViewer); +} + +void ViewerCreationState::onExit(QEvent* event) { + if (! cancelled) { + domViewerExtension->viewer(); + } + else { + if (domViewer != nullptr) { + delete domViewer; + domViewer = nullptr; + } + } +} + +void ViewerCreationState::viewerFinished() { + cancelled = false; + emit nextACS(); +} + +void ViewerCreationState::viewerCancelled() { + cancelled = true; + emit nextACS(); +} + +void ViewerCreationState::createSubStates(WizardMainWindow* mainWindow) { + viewerDescriptionWidget = new ViewerDescriptionWidget(nullptr); + viewerDescriptionState = new ViewerDescriptionState("Viewer Description", viewerDescriptionWidget, mainWindow, domCep, this); + + viewerSummaryWidget = new ViewerSummaryWidget(nullptr); + viewerSummaryState = new ViewerSummaryState("Viewer Summary", viewerSummaryWidget, mainWindow, this); + + this->setInitialState(viewerDescriptionState); + + viewerDescriptionState->addTransition(viewerDescriptionWidget, SIGNAL(next()), viewerSummaryState); + + QObject::connect(viewerDescriptionWidget, SIGNAL(cancel()), this, SLOT(viewerCancelled())); + QObject::connect(viewerSummaryWidget, SIGNAL(cancel()), this, SLOT(viewerCancelled())); + + QObject::connect(viewerSummaryWidget, SIGNAL(next()), this, SLOT(viewerFinished())); + +} diff --git a/sdk/applications/wizard/ViewerCreationState.h b/sdk/applications/wizard/ViewerCreationState.h new file mode 100644 index 0000000000000000000000000000000000000000..4cb98a27d1cf857bfc72ee1b66345a6fc3dc81c8 --- /dev/null +++ b/sdk/applications/wizard/ViewerCreationState.h @@ -0,0 +1,102 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWERCREATIONSTATE_H +#define VIEWERCREATIONSTATE_H + +#include +#include + +class WizardMainWindow; +class ViewerExtensionCreationState; + +// Sub-states +class ViewerDescriptionWidget; +class ViewerDescriptionState; +class ViewerSummaryWidget; +class ViewerSummaryState; + +// Dependency from cepcoreschema +// Declaration here to avoid declaration in dependant projects. +namespace cepcoreschema { +class ViewerExtension; +class Viewer; +class Cep; +} + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * State to create one action. + * + * This state manages sub-state to create one action. + * + */ +class ViewerCreationState : public QState { + + Q_OBJECT; + +public: + /** Constructor */ + ViewerCreationState(QString name, WizardMainWindow* mainWidnow, cepcoreschema::Cep* domCep, ViewerExtensionCreationState* parent); + + /** Destructor */ + ~ViewerCreationState() override = default; + + void resetDomViewerExtension(cepcoreschema::ViewerExtension* domViewerExtension); + +signals: + void nextACS(); + +public slots: + virtual void viewerFinished(); + virtual void viewerCancelled(); + +protected: + /// Reimplemented from QState + /// @{ + void onEntry(QEvent* event) override; + + void onExit(QEvent* event) override; + ///@} + + /// Substates (to be updated with domAction at each entry) + ViewerDescriptionWidget* viewerDescriptionWidget; + ViewerDescriptionState* viewerDescriptionState; + ViewerSummaryWidget* viewerSummaryWidget; + ViewerSummaryState* viewerSummaryState; + + +private: + void createSubStates(WizardMainWindow* mainWindow); + + bool cancelled; + QString name; + cepcoreschema::ViewerExtension* domViewerExtension; + cepcoreschema::Viewer* domViewer; + cepcoreschema::Cep* domCep; + +}; +#endif diff --git a/sdk/applications/wizard/ViewerDescriptionState.cpp b/sdk/applications/wizard/ViewerDescriptionState.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ff1f79fee158fdcbbb818e699da546b12d8ff578 --- /dev/null +++ b/sdk/applications/wizard/ViewerDescriptionState.cpp @@ -0,0 +1,110 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewerDescriptionState.h" +#include "ViewerDescriptionWidget.h" +#include "WizardMainWindow.h" +#include "ViewerCreationState.h" + +// includes from coreschema +#include +#include +#include +#include +#include + +// includes from cepgenerator +#include + +// temporary +#include + +ViewerDescriptionState::ViewerDescriptionState(QString name, ViewerDescriptionWidget* widget, WizardMainWindow* mainWindow, cepcoreschema::Cep* domCep, ViewerCreationState* parent) + : WizardState(name, widget, mainWindow, parent) { + this->domViewer = nullptr; + this->domViewerExtension = nullptr; + this->domCep = domCep; +} + +void ViewerDescriptionState::resetDomViewer(cepcoreschema::Viewer* domViewer, cepcoreschema::ViewerExtension* domViewerExtension) { + this->domViewer = domViewer; + this->domViewerExtension = domViewerExtension; + auto* viewerDescriptionWidget = dynamic_cast(widget); + if (viewerDescriptionWidget) { + QString viewerExtensionName = domViewerExtension->name().c_str(); + viewerDescriptionWidget->setToDefault(viewerExtensionName); + } +} + +void ViewerDescriptionState::onEntry(QEvent* event) { + WizardState::onEntry(event); + auto* viewerDescriptionWidget = dynamic_cast(widget); + if (viewerDescriptionWidget) { + QString ViewerExtensionName = domViewerExtension->name().c_str(); + viewerDescriptionWidget->setToDefault(ViewerExtensionName); + if ((domViewer != NULL) && (QString("A Viewer") != QString(domViewer->name().c_str()))) { + viewerDescriptionWidget->setName(QString(domViewer->name().c_str())); + viewerDescriptionWidget->setDescription(QString(domViewer->description().c_str())); + } + + // Check existing CEP viewers + // CS: problem to get viewers name. + // The loop was under viewer extension, the corresction is to loop under viewers for each viewerExtension. + // if (domCep->viewerExtensions().present()) { + // cepcoreschema::ViewerExtensions::viewerExtension_sequence cepViewerExtensions = domCep->viewerExtensions().get().viewerExtension(); + // cepcoreschema::ViewerExtensions::viewerExtension_iterator itCompExt; + // // Loop on viewerExtensions + // for (itCompExt = cepViewerExtensions.begin(); itCompExt != cepViewerExtensions.end(); itCompExt++) { + // cepcoreschema::Viewers::viewer_iterator itComp; + // // Loop on viewers for each viewerExtension. + // for (itComp = itCompExt->viewers().viewer().begin(); itComp != itCompExt->viewers().viewer().end(); itComp++) { + // QString viewerName = (*itComp).name().c_str(); + //viewerName = ClassNameHandler::getClassName(viewerName); + // } + // } + // } + } + +} + +void ViewerDescriptionState::onExit(QEvent* event) { + WizardState::onExit(event); + auto* viewerDescriptionWidget = dynamic_cast(widget); + + if (viewerDescriptionWidget) { + QString viewerName = viewerDescriptionWidget->getViewerName(); + QString viewerDescription = viewerDescriptionWidget->getViewerDescription(); + cepcoreschema::ViewerType type = viewerDescriptionWidget->getType(); + + domViewer->name(viewerName.toStdString()); + domViewer->description(viewerDescription.toStdString()); + domViewer->type(type); + } + + domViewerExtension->viewer(*domViewer); + std::cout << domViewer->name() << std::endl; + std::cout << domViewer->description() << std::endl; +} diff --git a/sdk/applications/wizard/ViewerDescriptionState.h b/sdk/applications/wizard/ViewerDescriptionState.h new file mode 100644 index 0000000000000000000000000000000000000000..5ef2430aa83cb9dcec3b947967f4856d5a945703 --- /dev/null +++ b/sdk/applications/wizard/ViewerDescriptionState.h @@ -0,0 +1,74 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWERDESCRIPTIONSTATE_H +#define VIEWERDESCRIPTIONSTATE_H + +#include "WizardState.h" + +class ViewerDescriptionWidget; +class ViewerCreationState; + +// Dependency from cepcoreschema +// Declaration here to avoid declaration in dependant projects. +namespace cepcoreschema { +class Viewer; +class ViewerExtension; +class Cep; +} + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * State to describe action + * + */ +class ViewerDescriptionState : public WizardState { + + Q_OBJECT; + +public: + /** Constructor */ + ViewerDescriptionState(QString name, ViewerDescriptionWidget* widget, WizardMainWindow* mainWindow, cepcoreschema::Cep* domCep, ViewerCreationState* parent); + + /** Destructor */ + ~ViewerDescriptionState() override = default; + + void resetDomViewer(cepcoreschema::Viewer* domViewer, cepcoreschema::ViewerExtension* domViewerExtension); + +protected: + void onExit(QEvent* event) override; + void onEntry(QEvent* event) override; + +private: + // Dom element that will be completed with the name + cepcoreschema::Viewer* domViewer; + // Just to check that the name of the Action is not the same of the Action Extension + cepcoreschema::ViewerExtension* domViewerExtension; + // To know which Components are available within the CEP (ot possibly apply the Action on). + cepcoreschema::Cep* domCep; + +}; +#endif diff --git a/sdk/applications/wizard/ViewerDescriptionWidget.cpp b/sdk/applications/wizard/ViewerDescriptionWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b96caec62dc08735c3c90ecec8d225e286a58b7f --- /dev/null +++ b/sdk/applications/wizard/ViewerDescriptionWidget.cpp @@ -0,0 +1,127 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewerDescriptionWidget.h" + +#include "DefaultGUIText.h" + +// Qt files +#include + +#include + +ViewerDescriptionWidget::ViewerDescriptionWidget(QWidget* parent) : QWidget(parent) { + ui.setupUi(this); + setToDefault(defaultViewerExtensionName); +} + +void ViewerDescriptionWidget::nextButtonClicked() { + QString viewerName = ui.viewerNameItself->text(); + QString viewerDescription = ui.viewerGoalItself->toPlainText(); +#ifndef _WIZARD_QUESTIONS_SQUEEZE + if (viewerName == viewerExtensionName) { + ui.viewerNameStar->setStyleSheet(enhancedStyle); + ui.viewerGoalStar->setStyleSheet(normalStyle); + ui.requiredLabel->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(this, defaultBeforeGoingFurther, defaultViewerNameAndExtension); + } + else if (viewerName.toUtf8() != viewerName.toLatin1()) { + ui.viewerNameStar->setStyleSheet(enhancedStyle); + ui.viewerGoalStar->setStyleSheet(normalStyle); + ui.requiredLabel->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(this, defaultBeforeGoingFurther, defaultAscii); + } + else if ((viewerName.isEmpty()) || (viewerName == defaultViewerName)) { + ui.viewerNameStar->setStyleSheet(enhancedStyle); + ui.viewerGoalStar->setStyleSheet(normalStyle); + ui.requiredLabel->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(this, defaultBeforeGoingFurther, defaultRealViewerName); + } + else if (viewerDescription.toUtf8() != viewerDescription.toLatin1()) { + ui.viewerNameStar->setStyleSheet(normalStyle); + ui.viewerGoalStar->setStyleSheet(enhancedStyle); + ui.requiredLabel->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(this, defaultBeforeGoingFurther, defaultAscii); + } + else if ((viewerDescription.isEmpty()) || (viewerDescription == defaultViewerDescription)) { + ui.viewerNameStar->setStyleSheet(normalStyle); + ui.viewerGoalStar->setStyleSheet(enhancedStyle); + ui.requiredLabel->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(this, defaultBeforeGoingFurther, defaultRealViewerDescription); + } + else { + emit next(); + } +#else + emit next(); +#endif +} + +void ViewerDescriptionWidget::cancelButtonClicked() { + emit cancel(); +} + + +QString ViewerDescriptionWidget::getViewerName() { + return ui.viewerNameItself->text(); +} + +QString ViewerDescriptionWidget::getViewerDescription() { + return ui.viewerGoalItself->toPlainText(); +} + +cepcoreschema::ViewerType ViewerDescriptionWidget::getType() { + return cepcoreschema::ViewerType::EMBEDDED; +} + +void ViewerDescriptionWidget::setToDefault(QString viewerExtensionName) { + + this->viewerExtensionName = viewerExtensionName; + + ui.viewerNameItself->setText(defaultViewerName); + ui.viewerGoalItself->setPlainText(defaultViewerDescription); + ui.viewerNameStar->setStyleSheet(normalStyle); + ui.viewerGoalStar->setStyleSheet(normalStyle); + ui.requiredLabel->setStyleSheet(normalStyle); +} + +void ViewerDescriptionWidget::setName(QString name) { + ui.viewerNameItself->setText(name); +} + +void ViewerDescriptionWidget::setDescription(QString description) { + ui.viewerGoalItself->setPlainText(description); +} \ No newline at end of file diff --git a/sdk/applications/wizard/ViewerDescriptionWidget.h b/sdk/applications/wizard/ViewerDescriptionWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..1181c3400ff53d9676d48074dcb5b298ab36827a --- /dev/null +++ b/sdk/applications/wizard/ViewerDescriptionWidget.h @@ -0,0 +1,78 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWERDESCRIPTIONWIDGET_H +#define VIEWERDESCRIPTIONWIDGET_H + +// Include GUI automatically generated file +#include "ui_ViewerDescriptionWidget.h" + +// includes from Qt +#include + +#include + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * Widget to describe action + * + */ +class ViewerDescriptionWidget : public QWidget { + + Q_OBJECT; + +public: + /** Constructor * */ + ViewerDescriptionWidget(QWidget* parent); + + /** Destructor */ + ~ViewerDescriptionWidget() override = default; + + void setToDefault(QString viewerExtensionName); + + void setName(QString name); + void setDescription(QString description); + void setComponent(QString component); + + QString getViewerName(); + QString getViewerDescription(); + cepcoreschema::ViewerType getType(); + QString getOutputType(); + +public slots: + virtual void nextButtonClicked(); + virtual void cancelButtonClicked(); + +signals: + void next(); + void cancel(); + +private: + Ui::ViewerDescriptionWidget ui; + + QString viewerExtensionName; +}; +#endif diff --git a/sdk/applications/wizard/ViewerDescriptionWidget.ui b/sdk/applications/wizard/ViewerDescriptionWidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..9b401e3207945317ccbd92b4ca7e140f1e0c320e --- /dev/null +++ b/sdk/applications/wizard/ViewerDescriptionWidget.ui @@ -0,0 +1,871 @@ + + + ViewerDescriptionWidget + + + + 0 + 0 + 759 + 630 + + + + Form + + + + + + 3 + + + + + + + + 0 + 0 + + + + + Sans Serif + 8 + 50 + false + + + + Viewer-extension + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + Sans Serif + 9 + 75 + false + true + + + + Viewer(s) + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + Sans Serif + 8 + 50 + false + + + + Dependencies + + + Qt::AlignCenter + + + + + + + + Sans Serif + 8 + + + + Summary + + + Qt::AlignCenter + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + true + + + + 0 + 0 + + + + + 1 + 1 + + + + + 1 + 1 + + + + + Sans Serif + 8 + 50 + false + + + + 1 + + + Qt::AlignCenter + + + 0 + + + + + + + + 0 + 0 + + + + + 110 + 0 + + + + + 70 + 0 + + + + Qt::Horizontal + + + + + + + + Sans Serif + 9 + 75 + false + true + + + + 2 + + + Qt::AlignCenter + + + + + + + + 70 + 0 + + + + + 70 + 0 + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + 50 + false + + + + 3 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + + + + 2 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + 3 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 85 + 20 + + + + + + + + + 0 + 0 + + + + + Sans Serif + 9 + 75 + true + + + + Description + + + Qt::AlignCenter + + + + + + + + Sans Serif + 8 + + + + Summary + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 85 + 20 + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 105 + 20 + + + + + + + + true + + + + 0 + 0 + + + + + 1 + 1 + + + + + 1 + 1 + + + + + Sans Serif + 9 + 75 + true + + + + 1 + + + Qt::AlignCenter + + + 0 + + + + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + + + + 4 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 105 + 20 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 1 + + + 1 + + + + + + Sans Serif + 11 + + + + Name of your viewer: + + + + + + + + + + 32 + 32 + + + + + 32 + 32 + + + + <html><head/><body><p>Give a precise description of what your viewer will do.</p></body></html> + + + + + + :/resources/Help.png + + + true + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + background-color: rgb(255, 255, 255); + + + + + + + + + + IBeamCursor + + + background-color: rgb(255, 255, 255); + + + true + + + + + + + + + + + 20 + 0 + + + + + 20 + 16777215 + + + + * + + + Qt::AlignCenter + + + + + + + + 20 + 0 + + + + + 20 + 16777215 + + + + * + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + + Sans Serif + 11 + + + + Goal(s) of your viewer: + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + + 32 + 32 + + + + + 32 + 32 + + + + <html><head/><body><p>Give a meaningful name to your viewer.</p></body></html> + + + + + + + + + :/resources/Help.png + + + true + + + Qt::AlignCenter + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + * <i>required field</i> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 9 + + + + Cancel + + + + :/resources/button_cancel.png:/resources/button_cancel.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 64 + 32 + + + + + 128 + 32 + + + + + 9 + + + + Qt::RightToLeft + + + Next + + + + :/resources/rightarrow.png:/resources/rightarrow.png + + + + 16 + 16 + + + + true + + + + + + + + + + + + + nextPushButton + clicked() + ViewerDescriptionWidget + nextButtonClicked() + + + 649 + 604 + + + 647 + 577 + + + + + componentComboBox + currentIndexChanged(QString) + ViewerDescriptionWidget + componentChanged(QString) + + + 491 + 381 + + + 494 + 417 + + + + + cancelPushButton + clicked() + ViewerDescriptionWidget + cancelButtonClicked() + + + 313 + 598 + + + 268 + 579 + + + + + + componentChanged(QString) + nextButtonClicked() + itkFilterClicked(bool) + cancelButtonClicked() + + diff --git a/sdk/applications/wizard/ViewerExtensionCreationState.cpp b/sdk/applications/wizard/ViewerExtensionCreationState.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cd1b29de8522a7da90cbf384688a5323d912884e --- /dev/null +++ b/sdk/applications/wizard/ViewerExtensionCreationState.cpp @@ -0,0 +1,136 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewerExtensionCreationState.h" +#include "WizardMainWindow.h" + +#include "ViewerExtensionDescriptionWidget.h" +#include "ViewerExtensionDescriptionState.h" +#include "ViewersCreationWidget.h" +#include "ViewersCreationState.h" +#include "ViewerCreationState.h" +#include "ViewerExtensionDependenciesState.h" +#include "DependenciesWidget.h" +#include "ExtensionSummaryWidget.h" +#include "ExtensionSummaryState.h" + +#include +#include +#include + +ViewerExtensionCreationState::ViewerExtensionCreationState(QString name, WizardMainWindow* mainWindow, cepcoreschema::Cep* domCep) : QState() { + this->cancelled = false; + this->name = name; + this->domCep = domCep; + this->domViewerExtension = nullptr; + + createSubStates(mainWindow); +} + +void ViewerExtensionCreationState::onEntry(QEvent* event) { + this->cancelled = false; + if (this->domViewerExtension != nullptr) { + delete domViewerExtension; + domViewerExtension = nullptr; + } + + cepcoreschema::Viewer theViewer("A Viewer", "A viewer description", cepcoreschema::ViewerType::EMBEDDED); + this->domViewerExtension = new cepcoreschema::ViewerExtension("A Viewer Extension", "A viewer extension description", theViewer); + + viewerExtensionDescriptionState->resetDomViewerExtension(domViewerExtension); + viewerExtensionDependenciesState->resetDomViewerExtension(domViewerExtension); + viewerExtensionSummaryState->setViewerExtension(domViewerExtension); + viewersCreationState->resetDomViewerExtension(domViewerExtension); + viewerCreationState->resetDomViewerExtension(domViewerExtension); +} + +void ViewerExtensionCreationState::onExit(QEvent* event) { + if (! cancelled) { + if (domCep->viewerExtensions().present()) { + domCep->viewerExtensions().get().viewerExtension().push_back((*domViewerExtension)); + } + else { + cepcoreschema::ViewerExtensions theExtensions; + theExtensions.viewerExtension().push_back((*domViewerExtension)); + domCep->viewerExtensions(theExtensions); + } + } + else { + if (domViewerExtension != nullptr) { + delete domViewerExtension; + domViewerExtension = nullptr; + } + } + +} + + +void ViewerExtensionCreationState::extensionFinished() { + cancelled = false; + emit next(); +} + +void ViewerExtensionCreationState::extensionCancelled() { + cancelled = true; + emit next(); +} + +void ViewerExtensionCreationState::createSubStates(WizardMainWindow* mainWindow) { + viewerExtensionDescriptionWidget = new ViewerExtensionDescriptionWidget(nullptr); + viewerExtensionDescriptionState = new ViewerExtensionDescriptionState("Viewer Extension", viewerExtensionDescriptionWidget, mainWindow, this); + + viewersCreationWidget = new ViewersCreationWidget(nullptr); + viewersCreationState = new ViewersCreationState("Viewers Creation", viewersCreationWidget, mainWindow, this); + + viewerCreationState = new ViewerCreationState("Viewer Creation", mainWindow, domCep, this); + + viewerExtensionDependenciesWidget = new DependenciesWidget(nullptr); + viewerExtensionDependenciesState = new ViewerExtensionDependenciesState("Viewer Extension Dependencies", viewerExtensionDependenciesWidget, mainWindow, domCep, this); + + viewerExtensionSummaryWidget = new ExtensionSummaryWidget(nullptr); + viewerExtensionSummaryState = new ExtensionSummaryState("Viewer Extension Summary", viewerExtensionSummaryWidget, "Viewer", mainWindow, this); + + viewerExtensionDescriptionState->addTransition(viewerExtensionDescriptionWidget, SIGNAL(next()), viewerCreationState); + viewersCreationState->addTransition(viewersCreationWidget, SIGNAL(newViewer()), viewerCreationState); + viewersCreationState->addTransition(viewersCreationWidget, SIGNAL(next()), viewerExtensionDependenciesState); + viewersCreationState->addTransition(viewersCreationWidget, SIGNAL(previous()), viewerExtensionDescriptionState); + + viewerCreationState->addTransition(viewerCreationState, SIGNAL(nextACS()), viewersCreationState); + + viewerExtensionDependenciesState->addTransition(viewerExtensionDependenciesWidget, SIGNAL(previous()), viewersCreationState); + viewerExtensionDependenciesState->addTransition(viewerExtensionDependenciesWidget, SIGNAL(next()), viewerExtensionSummaryState); + + viewerExtensionSummaryState->addTransition(viewerExtensionSummaryWidget, SIGNAL(previous()), viewerExtensionDependenciesState); + QObject::connect(viewerExtensionSummaryWidget, SIGNAL(next()), this, SLOT(extensionFinished())); + + // Cancel + QObject::connect(viewerExtensionDescriptionWidget, SIGNAL(cancel()), this, SLOT(extensionCancelled())); + QObject::connect(viewersCreationWidget, SIGNAL(cancel()), this, SLOT(extensionCancelled())); + QObject::connect(viewerExtensionDependenciesWidget, SIGNAL(cancel()), this, SLOT(extensionCancelled())); + QObject::connect(viewerExtensionSummaryWidget, SIGNAL(cancel()), this, SLOT(extensionCancelled())); + + this->setInitialState(viewerExtensionDescriptionState); +} diff --git a/sdk/applications/wizard/ViewerExtensionCreationState.h b/sdk/applications/wizard/ViewerExtensionCreationState.h new file mode 100644 index 0000000000000000000000000000000000000000..11f3af284f8db24809f5101e499d567e5ffdbef8 --- /dev/null +++ b/sdk/applications/wizard/ViewerExtensionCreationState.h @@ -0,0 +1,108 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWEREXTENSIONCREATIONSTATE_H +#define VIEWEREXTENSIONCREATIONSTATE_H + +#include +#include + +class WizardMainWindow; +// Sub states +class ViewerExtensionDescriptionWidget; +class ViewerExtensionDescriptionState; +class ViewersCreationWidget; +class ViewersCreationState; +class ViewerCreationState; +class DependenciesWidget; +class ViewerExtensionDependenciesState; +class ExtensionSummaryWidget; +class ExtensionSummaryState; + +// Dependency from cepcoreschema +// Declaration here to avoid declaration in dependant projects. +namespace cepcoreschema { +class Cep; +class ViewerExtension; +} + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * State to create an action extension. \n + * + * This state enables to create all states to generate one or more actions. \n + * It manages a sub-states dedicated to the creation of actions. + * + */ +class ViewerExtensionCreationState : public QState { + + Q_OBJECT; + +public: + /** Constructor */ + ViewerExtensionCreationState(QString name, WizardMainWindow* mainWidnow, cepcoreschema::Cep* domCep); + + /** Destructor */ + ~ViewerExtensionCreationState() override = default; + +signals: + void next(); + +public slots: + virtual void extensionFinished(); + virtual void extensionCancelled(); + +protected: + /// Reimplemented from QState + /// @{ + void onEntry(QEvent* event) override; + + void onExit(QEvent* event) override; + ///@} + +private: + + bool cancelled; + + // Sub States + ViewerExtensionDescriptionWidget* viewerExtensionDescriptionWidget; + ViewerExtensionDescriptionState* viewerExtensionDescriptionState; + ViewersCreationWidget* viewersCreationWidget; + ViewersCreationState* viewersCreationState; + ViewerCreationState* viewerCreationState; + DependenciesWidget* viewerExtensionDependenciesWidget; + ViewerExtensionDependenciesState* viewerExtensionDependenciesState; + ExtensionSummaryWidget* viewerExtensionSummaryWidget; + ExtensionSummaryState* viewerExtensionSummaryState; + + void createSubStates(WizardMainWindow* mainWindow); + + QString name; + cepcoreschema::Cep* domCep; + cepcoreschema::ViewerExtension* domViewerExtension; + +}; +#endif diff --git a/sdk/applications/wizard/ViewerExtensionDependenciesState.cpp b/sdk/applications/wizard/ViewerExtensionDependenciesState.cpp new file mode 100644 index 0000000000000000000000000000000000000000..439e2075ae3b416dba557220105425b2e1bb314b --- /dev/null +++ b/sdk/applications/wizard/ViewerExtensionDependenciesState.cpp @@ -0,0 +1,74 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewerExtensionDependenciesState.h" +#include "WizardMainWindow.h" +#include "ViewerExtensionCreationState.h" +#include "DependenciesWidget.h" + +// includes from coreschema +#include +#include + +ViewerExtensionDependenciesState::ViewerExtensionDependenciesState(QString name, DependenciesWidget* widget, WizardMainWindow* mainWindow, cepcoreschema::Cep* domCep, ViewerExtensionCreationState* parent) + : DependenciesState(name, widget, mainWindow, domCep, parent) { + this->domViewerExtension = nullptr; + widget->setElement("Viewer Extension"); +} + +void ViewerExtensionDependenciesState::resetDomViewerExtension(cepcoreschema::ViewerExtension* domViewerExtension) { + this->domViewerExtension = domViewerExtension; + auto* dependenciesWidget = dynamic_cast(widget); + if (dependenciesWidget != nullptr) { + dependenciesWidget->setToDefault(); + } +} + +void ViewerExtensionDependenciesState::onEntry(QEvent* event) { + DependenciesState::onEntry(event); + auto* dependenciesWidget = dynamic_cast(widget); + if (dependenciesWidget != nullptr) { + // Look for itk dependencies + if (isItkDependant(domViewerExtension)) { + dependenciesWidget->setItkDependency(true); + } + } +} + + +void ViewerExtensionDependenciesState::onExit(QEvent* event) { + DependenciesState::onExit(event); + cepcoreschema::Dependencies* domDeps = getDependencies(); + if (domDeps != nullptr) { + if (domDeps->dependency().size() > 0) { + domViewerExtension->dependencies((*domDeps)); + } + } +} + +bool ViewerExtensionDependenciesState::isItkDependant(cepcoreschema::ViewerExtension* domExtension) { + return false; +} diff --git a/sdk/applications/wizard/ViewerExtensionDependenciesState.h b/sdk/applications/wizard/ViewerExtensionDependenciesState.h new file mode 100644 index 0000000000000000000000000000000000000000..befcd85bf11991b442ec218cc8048fed27ea5457 --- /dev/null +++ b/sdk/applications/wizard/ViewerExtensionDependenciesState.h @@ -0,0 +1,70 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWEREXTENSIONDEPENDENCIESSTATE_H +#define VIEWEREXTENSIONDEPENDENCIESSTATE_H + +#include "DependenciesState.h" + +class ViewerExtensionCreationState; + +// Dependency from cepcoreschema +// Declaration here to avoid declaration in dependant projects. +namespace cepcoreschema { +class ViewerExtension; +} + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * State to define action extension dependencies + * + */ +class ViewerExtensionDependenciesState : public DependenciesState { + + Q_OBJECT; + +public: + /** Constructor */ + ViewerExtensionDependenciesState(QString name, DependenciesWidget* widget, WizardMainWindow* mainWindow, cepcoreschema::Cep* domCep, ViewerExtensionCreationState* parent); + + /** Destructor */ + ~ViewerExtensionDependenciesState() override = default; + + void resetDomViewerExtension(cepcoreschema::ViewerExtension* domViewerExtension); + + cepcoreschema::ViewerExtension* domViewerExtension; + +protected: + void onEntry(QEvent* event) override; + void onExit(QEvent* event) override; + +private: + bool isItkDependant(cepcoreschema::ViewerExtension* domExtension); + + + +}; +#endif diff --git a/sdk/applications/wizard/ViewerExtensionDescriptionState.cpp b/sdk/applications/wizard/ViewerExtensionDescriptionState.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9b9192a55fbc20b17155e3a9d90ec1e0866eb1d6 --- /dev/null +++ b/sdk/applications/wizard/ViewerExtensionDescriptionState.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewerExtensionDescriptionState.h" +#include "ViewerExtensionDescriptionWidget.h" +#include "WizardMainWindow.h" +#include "ViewerExtensionCreationState.h" + +// includes from coreschema +#include + +ViewerExtensionDescriptionState::ViewerExtensionDescriptionState(QString name, ViewerExtensionDescriptionWidget* widget, WizardMainWindow* mainWindow, ViewerExtensionCreationState* parent) + : WizardState(name, widget, mainWindow, parent) { + this->domViewerExtension = nullptr; +} + +void ViewerExtensionDescriptionState::resetDomViewerExtension(cepcoreschema::ViewerExtension* domViewerExtension) { + this->domViewerExtension = domViewerExtension; + auto* viewerExtensionDescriptionWidget = dynamic_cast(widget); + if (viewerExtensionDescriptionWidget != nullptr) { + viewerExtensionDescriptionWidget->setToDefault(); + } +} + +void ViewerExtensionDescriptionState::onExit(QEvent* event) { + WizardState::onExit(event); + auto* viewerExtensionDescriptionWidget = dynamic_cast(widget); + if (viewerExtensionDescriptionWidget != nullptr) { + QString viewerExtensionName = viewerExtensionDescriptionWidget->getViewerExtensionName(); + QString viewerExtensionDescription = viewerExtensionDescriptionWidget->getCepDescription(); + domViewerExtension->name(viewerExtensionName.toStdString()); + domViewerExtension->description(viewerExtensionDescription.toStdString()); + } +} diff --git a/sdk/applications/wizard/ViewerExtensionDescriptionState.h b/sdk/applications/wizard/ViewerExtensionDescriptionState.h new file mode 100644 index 0000000000000000000000000000000000000000..893ba3292dd8e94d58e0dec342040744a4d377e8 --- /dev/null +++ b/sdk/applications/wizard/ViewerExtensionDescriptionState.h @@ -0,0 +1,67 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWEREXTENSIONDESCRIPTIONSTATE_H +#define VIEWEREXTENSIONDESCRIPTIONSTATE_H + +#include "WizardState.h" + +class ViewerExtensionDescriptionWidget; +class ViewerExtensionCreationState; + +// Dependency from cepcoreschema +// Declaration here to avoid declaration in dependant projects. +namespace cepcoreschema { +class ViewerExtension; +} + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * State to enter the action extension description + * + */ +class ViewerExtensionDescriptionState : public WizardState { + + Q_OBJECT; + +public: + /** Constructor */ + ViewerExtensionDescriptionState(QString name, ViewerExtensionDescriptionWidget* widget, WizardMainWindow* mainWindow, ViewerExtensionCreationState* parent); + + /** Destructor */ + ~ViewerExtensionDescriptionState() override = default; + + void resetDomViewerExtension(cepcoreschema::ViewerExtension* domViewerExtension); + + +protected: + void onExit(QEvent* event) override; + +private: + cepcoreschema::ViewerExtension* domViewerExtension; + +}; +#endif diff --git a/sdk/applications/wizard/ViewerExtensionDescriptionWidget.cpp b/sdk/applications/wizard/ViewerExtensionDescriptionWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bbbb4520dc106915d681ab99a2f86e77a7e09c0a --- /dev/null +++ b/sdk/applications/wizard/ViewerExtensionDescriptionWidget.cpp @@ -0,0 +1,108 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewerExtensionDescriptionWidget.h" + +#include "DefaultGUIText.h" + +// Qt files +#include + + +ViewerExtensionDescriptionWidget::ViewerExtensionDescriptionWidget(QWidget* parent) : QWidget(parent) { + ui.setupUi(this); +} + +void ViewerExtensionDescriptionWidget::cancelButtonClicked() { + emit cancel(); +} + +void ViewerExtensionDescriptionWidget::nextButtonClicked() { + QString viewerExtensionName = ui.viewerExtensionNameItself->text(); + QString viewerExtensionDescription = ui.viewerExtensionDescriptionItself->toPlainText(); + +#ifndef _WIZARD_QUESTIONS_SQUEEZE + if (viewerExtensionName.toUtf8() != viewerExtensionName.toLatin1()) { + ui.viewerExtensionNameStar->setStyleSheet(enhancedStyle); + ui.viewerExtensionDescriptionStar->setStyleSheet(normalStyle); + ui.requiredLabel->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(this, defaultBeforeGoingFurther, defaultAscii); + } + else if ((viewerExtensionName.isEmpty()) || (viewerExtensionName == defaultViewerExtensionName)) { + ui.viewerExtensionNameStar->setStyleSheet(enhancedStyle); + ui.viewerExtensionDescriptionStar->setStyleSheet(normalStyle); + ui.requiredLabel->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(this, defaultBeforeGoingFurther, defaultRealExtensionName); + } + else if (viewerExtensionDescription.toUtf8() != viewerExtensionDescription.toLatin1()) { + ui.viewerExtensionNameStar->setStyleSheet(normalStyle); + ui.viewerExtensionDescriptionStar->setStyleSheet(enhancedStyle); + ui.requiredLabel->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(this, defaultBeforeGoingFurther, defaultAscii); + } + else if ((viewerExtensionDescription.isEmpty()) || (viewerExtensionDescription == defaultViewerExtensionDescription)) { + ui.viewerExtensionNameStar->setStyleSheet(normalStyle); + ui.viewerExtensionDescriptionStar->setStyleSheet(enhancedStyle); + ui.requiredLabel->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(this, defaultBeforeGoingFurther, defaultRealExtensionDescription); + } + else { + ui.viewerExtensionNameStar->setStyleSheet(normalStyle); + ui.viewerExtensionDescriptionStar->setStyleSheet(normalStyle); + ui.requiredLabel->setStyleSheet(normalStyle); + emit next(); + } +#else + emit next(); +#endif +} + +void ViewerExtensionDescriptionWidget::setToDefault() { + ui.explanationLabel->setText(defaultViewerExtensionExplanation); + ui.viewerExtensionNameItself->setText(defaultViewerExtensionName); + ui.viewerExtensionDescriptionItself->setPlainText(defaultViewerExtensionDescription); + ui.viewerExtensionNameStar->setStyleSheet(normalStyle); + ui.viewerExtensionDescriptionStar->setStyleSheet(normalStyle); + ui.requiredLabel->setStyleSheet(normalStyle); +} + +QString ViewerExtensionDescriptionWidget::getViewerExtensionName() { + return ui.viewerExtensionNameItself->text(); +} + +QString ViewerExtensionDescriptionWidget::getCepDescription() { + return ui.viewerExtensionDescriptionItself->toPlainText(); +} + + diff --git a/sdk/applications/wizard/ViewerExtensionDescriptionWidget.h b/sdk/applications/wizard/ViewerExtensionDescriptionWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..d9868cb3727beb943a4c9c1cbdb7fbfe464340f0 --- /dev/null +++ b/sdk/applications/wizard/ViewerExtensionDescriptionWidget.h @@ -0,0 +1,68 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWEREXTENSIONDESCRIPTIONWIDGET_H +#define VIEWEREXTENSIONDESCRIPTIONWIDGET_H + +// Include GUI automatically generated file +#include "ui_ViewerExtensionDescriptionWidget.h" + +// includes from Qt +#include + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * Widget to enter the action extension description + * + */ +class ViewerExtensionDescriptionWidget : public QWidget { + + Q_OBJECT; + +public: + /** Constructor */ + ViewerExtensionDescriptionWidget(QWidget* parent); + + /** Destructor */ + ~ViewerExtensionDescriptionWidget() override = default; + + void setToDefault(); + QString getViewerExtensionName(); + QString getCepDescription(); + +public slots: + virtual void nextButtonClicked(); + virtual void cancelButtonClicked(); + +signals: + void next(); + void cancel(); + +private: + + Ui::ViewerExtensionDescriptionWidget ui; +}; +#endif diff --git a/sdk/applications/wizard/ViewerExtensionDescriptionWidget.ui b/sdk/applications/wizard/ViewerExtensionDescriptionWidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..5043b17a00e1b1b57687834bff3039d7bf7ae294 --- /dev/null +++ b/sdk/applications/wizard/ViewerExtensionDescriptionWidget.ui @@ -0,0 +1,766 @@ + + + ViewerExtensionDescriptionWidget + + + + 0 + 0 + 727 + 635 + + + + Form + + + + + + 3 + + + + + + + + 0 + 0 + + + + + Sans Serif + 9 + 75 + true + + + + Viewer-extension + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + Sans Serif + 8 + 50 + false + false + + + + Viewer + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + Sans Serif + 8 + 50 + false + + + + Dependencies + + + Qt::AlignCenter + + + + + + + + Sans Serif + 8 + + + + Summary + + + Qt::AlignCenter + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + true + + + + 0 + 0 + + + + + 1 + 1 + + + + + 1 + 1 + + + + + Sans Serif + 11 + 75 + true + + + + 1 + + + Qt::AlignCenter + + + 0 + + + + + + + + 0 + 0 + + + + + 110 + 0 + + + + + 70 + 0 + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + 50 + false + false + + + + 2 + + + Qt::AlignCenter + + + + + + + + 70 + 0 + + + + + 70 + 0 + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + 50 + false + + + + 3 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + + + + 4 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 32 + 32 + + + + + 64 + 64 + + + + + + + :/resources/viewer_bas.png + + + true + + + + + + + + 14 + + + + <html><head/><body><p><span style=" font-size:14pt; font-weight:600;">Create your Viewer Extension</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + + + + 1 + + + 1 + + + + + + Sans Serif + 11 + + + + Description + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 32 + 32 + + + + + 32 + 32 + + + + <html><head/><body><p>Give a meaningful name your viewer-extension. The name can corresponds to the overall processing performed by the extension.</p></body></html> + + + + + + :/resources/Help.png + + + true + + + Qt::AlignCenter + + + + + + + + + + + Arial + + + + IBeamCursor + + + Qt::StrongFocus + + + background-color: rgb(255, 255, 255); + + + true + + + + + + + + + + + Arial + + + + Qt::StrongFocus + + + false + + + background-color: rgb(255, 255, 255); + + + + + + + + + + + 20 + 0 + + + + + 20 + 16777215 + + + + * + + + Qt::AlignCenter + + + + + + + + 20 + 0 + + + + + 20 + 16777215 + + + + * + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + + Sans Serif + 11 + + + + Name + + + + + + + + + + 32 + 32 + + + + + 32 + 32 + + + + <html><head/><body><p>Give a precise description of what your viewer-extension will do.</p></body></html> + + + + + + :/resources/Help.png + + + true + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + * <i>required field</i> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 9 + + + + Cancel + + + + :/resources/button_cancel.png:/resources/button_cancel.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 64 + 32 + + + + + 128 + 32 + + + + + 9 + + + + Qt::RightToLeft + + + Next + + + + :/resources/rightarrow.png:/resources/rightarrow.png + + + + 16 + 16 + + + + true + + + + + + + + + + + + + nextPushButton + clicked() + ViewerExtensionDescriptionWidget + nextButtonClicked() + + + 668 + 606 + + + 653 + 582 + + + + + cancelPushButton + clicked() + ViewerExtensionDescriptionWidget + cancelButtonClicked() + + + 311 + 611 + + + 238 + 589 + + + + + + nextButtonClicked() + cancelButtonClicked() + + diff --git a/sdk/applications/wizard/ViewerSummaryState.cpp b/sdk/applications/wizard/ViewerSummaryState.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c3d0b8bb8136804e4eb184012edab68cb2918d02 --- /dev/null +++ b/sdk/applications/wizard/ViewerSummaryState.cpp @@ -0,0 +1,69 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewerSummaryState.h" +#include "ViewerSummaryWidget.h" + +#include "WizardMainWindow.h" + +// includes from coreschema +#include +#include + +#include + +ViewerSummaryState::ViewerSummaryState(QString name, ViewerSummaryWidget* widget, + WizardMainWindow* mainWindow, QState* parent) + : WizardState(name, widget, mainWindow, parent) { + this->domViewerExtension = nullptr; + this->domViewer = nullptr; +} + +void ViewerSummaryState::resetViewer(cepcoreschema::Viewer* domViewer) { + this->domViewer = domViewer; +} + +void ViewerSummaryState::onEntry(QEvent* event) { + WizardState::onEntry(event); + std::cout << "Viewer Summary State on Entry" << std::endl; + + auto* viewerSummaryWidget = dynamic_cast(widget); + if (viewerSummaryWidget != nullptr) { + if (domViewer != nullptr) { + std::cout << "domViewer non NULL" << std::endl; + QString name = domViewer->name().c_str(); + QString description = domViewer->description().c_str(); + + viewerSummaryWidget->setSummary(name, description); + } + } + +} + +void ViewerSummaryState::onExit(QEvent* event) { + WizardState::onExit(event); +} + diff --git a/sdk/applications/wizard/ViewerSummaryState.h b/sdk/applications/wizard/ViewerSummaryState.h new file mode 100644 index 0000000000000000000000000000000000000000..7116b5243711cfa2a344a569f4d879c024dd7661 --- /dev/null +++ b/sdk/applications/wizard/ViewerSummaryState.h @@ -0,0 +1,67 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWERSUMMARYSTATE_H +#define VIEWERSUMMARYSTATE_H + +#include "WizardState.h" + +class ViewerSummaryWidget; + +// Dependency from cepcoreschema +// Declaration here to avoid declaration in dependant projects. +namespace cepcoreschema { +class Viewer; +class ViewerExtension; +} + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * State to summarize the created action + * + */ +class ViewerSummaryState : public WizardState { + + Q_OBJECT; + +public: + /** Constructor*/ + ViewerSummaryState(QString name, ViewerSummaryWidget* widget, WizardMainWindow* mainWindow, QState* parent); + + /** Destructor*/ + ~ViewerSummaryState() override = default; + + void resetViewer(cepcoreschema::Viewer* domViewer); + +protected: + void onEntry(QEvent* event) override; + void onExit(QEvent* event) override; + + cepcoreschema::Viewer* domViewer; + cepcoreschema::ViewerExtension* domViewerExtension; + +}; +#endif diff --git a/sdk/applications/wizard/ViewerSummaryWidget.cpp b/sdk/applications/wizard/ViewerSummaryWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a0c6bb72d53c33cf21e83c2cbeb5c24b865d3dc --- /dev/null +++ b/sdk/applications/wizard/ViewerSummaryWidget.cpp @@ -0,0 +1,62 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewerSummaryWidget.h" + +#include "DefaultGUIText.h" + +ViewerSummaryWidget::ViewerSummaryWidget(QWidget* parent) : QWidget(parent) { + ui.setupUi(this); +} + +void ViewerSummaryWidget::setToDefault() { + ui.summaryLabel->setText(""); +} + +void ViewerSummaryWidget::nextButtonClicked() { + emit next(); +} + +void ViewerSummaryWidget::cancelButtonClicked() { + emit cancel(); +} + +void ViewerSummaryWidget::previousButtonClicked() { + emit previous(); +} + +void ViewerSummaryWidget::setSummary(QString name, QString description) { + QString text = defaultViewerSummary; + + text = text.replace(QRegExp("@NAME@"), name); + text = text.replace(QRegExp("@DESCRIPTION@"), description); + + ui.viewerSummaryLabel->setText(text); +} + + + + diff --git a/sdk/applications/wizard/ViewerSummaryWidget.h b/sdk/applications/wizard/ViewerSummaryWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..a4b885df250da145754a8955b1ffaef825e86664 --- /dev/null +++ b/sdk/applications/wizard/ViewerSummaryWidget.h @@ -0,0 +1,70 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWERSUMMARYWIDGET_H +#define VIEWERSUMMARYWIDGET_H + +// Include GUI automatically generated file +#include "ui_ViewerSummaryWidget.h" + +// includes from Qt +#include +#include + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * Widget to summarize the created action + * + */ +class ViewerSummaryWidget : public QWidget { + + Q_OBJECT; + +public: + /** Constructor */ + ViewerSummaryWidget(QWidget* parent); + + /** Destructor */ + ~ViewerSummaryWidget() override = default; + + void setToDefault(); + void setSummary(QString name, QString description); + +public slots: + virtual void nextButtonClicked(); + virtual void cancelButtonClicked(); + virtual void previousButtonClicked(); + +signals: + void next(); + void previous(); + void cancel(); + +private: + Ui::ViewerSummaryWidget ui; + +}; +#endif diff --git a/sdk/applications/wizard/ViewerSummaryWidget.ui b/sdk/applications/wizard/ViewerSummaryWidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..8cb9fc88b2289b6bb15a0817871cde1b465da18b --- /dev/null +++ b/sdk/applications/wizard/ViewerSummaryWidget.ui @@ -0,0 +1,617 @@ + + + ViewerSummaryWidget + + + + 0 + 0 + 723 + 629 + + + + Form + + + + + + 3 + + + + + + + + 0 + 0 + + + + + Sans Serif + 8 + 50 + false + + + + Viewer-extension + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + Sans Serif + 9 + 75 + false + true + + + + Viewer + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + Sans Serif + 8 + 50 + false + + + + Dependencies + + + Qt::AlignCenter + + + + + + + + Sans Serif + 8 + 50 + false + + + + Summary + + + Qt::AlignCenter + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + true + + + + 0 + 0 + + + + + 1 + 1 + + + + + 1 + 1 + + + + + Sans Serif + 8 + + + + 1 + + + Qt::AlignCenter + + + 0 + + + + + + + Qt::Horizontal + + + + + + + + Sans Serif + 9 + 75 + false + true + + + + 2 + + + Qt::AlignCenter + + + + + + + + 70 + 0 + + + + + 70 + 0 + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + 50 + false + + + + 3 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + 50 + false + + + + 2 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 85 + 20 + + + + + + + + + Sans Serif + 8 + + + + Description + + + Qt::AlignCenter + + + + + + + + Sans Serif + 9 + 75 + true + + + + Summary + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 85 + 20 + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 105 + 20 + + + + + + + + + Sans Serif + 8 + + + + 1 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + + Sans Serif + 9 + 75 + true + + + + 4 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 105 + 20 + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 9 + + + + Previous + + + + :/resources/leftarrow.png:/resources/leftarrow.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 9 + + + + Cancel + + + + :/resources/button_cancel.png:/resources/button_cancel.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 64 + 32 + + + + + 128 + 32 + + + + + 9 + + + + Qt::RightToLeft + + + Next + + + + :/resources/rightarrow.png:/resources/rightarrow.png + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + nextPushButton + clicked() + ViewerSummaryWidget + nextButtonClicked() + + + 710 + 616 + + + 682 + 530 + + + + + cancelPushButton + clicked() + ViewerSummaryWidget + cancelButtonClicked() + + + 424 + 616 + + + 249 + 628 + + + + + previousPushButton + clicked() + ViewerSummaryWidget + previousButtonClicked() + + + 91 + 616 + + + 18 + 628 + + + + + + nextButtonClicked() + cancelButtonClicked() + previousButtonClicked() + + diff --git a/sdk/applications/wizard/ViewersCreationState.cpp b/sdk/applications/wizard/ViewersCreationState.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a03f5a2eb2756e298a7ab6cdef5265ced95150ab --- /dev/null +++ b/sdk/applications/wizard/ViewersCreationState.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewersCreationState.h" +#include "ViewersCreationWidget.h" +#include "WizardMainWindow.h" +#include "ViewerExtensionCreationState.h" + +// includes from coreschema +#include +#include + +#include + +ViewersCreationState::ViewersCreationState(QString name, ViewersCreationWidget* widget, WizardMainWindow* mainWindow, ViewerExtensionCreationState* parent) + : WizardState(name, widget, mainWindow, parent) { + this->domViewerExtension = nullptr; +} + +void ViewersCreationState::resetDomViewerExtension(cepcoreschema::ViewerExtension* domViewerExtension) { + this->domViewerExtension = domViewerExtension; + auto* viewersCreationWidget = dynamic_cast(widget); + if (viewersCreationWidget != nullptr) { + viewersCreationWidget->setToDefault(); + } +} + +void ViewersCreationState::onEntry(QEvent* event) { + WizardState::onEntry(event); + + std::cout << domViewerExtension->name() << std::endl; + std::cout << domViewerExtension->description() << std::endl; + std::cout << domViewerExtension->viewer().name() << std::endl; + std::cout << domViewerExtension->viewer().description() << std::endl; +} + +void ViewersCreationState::onExit(QEvent* event) { + WizardState::onExit(event); +} + + diff --git a/sdk/applications/wizard/ViewersCreationState.h b/sdk/applications/wizard/ViewersCreationState.h new file mode 100644 index 0000000000000000000000000000000000000000..142d876242f6a62aae90dd572b7bb2ee3588f480 --- /dev/null +++ b/sdk/applications/wizard/ViewersCreationState.h @@ -0,0 +1,67 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWERSCREATIONSTATE_H +#define VIEWERSCREATIONSTATE_H + +#include "WizardState.h" + +class ViewersCreationWidget; +class ViewerExtensionCreationState; + +// Dependency from cepcoreschema +// Declaration here to avoid declaration in dependant projects. +namespace cepcoreschema { +class ViewerExtension; +} + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * State to create actions + * + */ +class ViewersCreationState : public WizardState { + + Q_OBJECT; + +public: + /** Constructor */ + ViewersCreationState(QString name, ViewersCreationWidget* widget, WizardMainWindow* mainWindow, ViewerExtensionCreationState* parent); + + /** Destructor */ + ~ViewersCreationState() override = default; + + void resetDomViewerExtension(cepcoreschema::ViewerExtension* domViewerExtension); + +protected: + void onEntry(QEvent* event) override; + void onExit(QEvent* event) override; + +private: + cepcoreschema::ViewerExtension* domViewerExtension; + +}; +#endif diff --git a/sdk/applications/wizard/ViewersCreationWidget.cpp b/sdk/applications/wizard/ViewersCreationWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f26a136869eeffbca63b551183495c24eb661eb1 --- /dev/null +++ b/sdk/applications/wizard/ViewersCreationWidget.cpp @@ -0,0 +1,100 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +// Include .h file +#include "ViewersCreationWidget.h" + +#include "DefaultGUIText.h" + +// Qt files +#include +#include + +ViewersCreationWidget::ViewersCreationWidget(QWidget* parent) : QWidget(parent) { + ui.setupUi(this); +} + +void ViewersCreationWidget::setToDefault() { + ui.requiredLabel->setStyleSheet(normalStyle); + ui.label_Star->setStyleSheet(normalStyle); + emptyExistingViewers(); +} + +void ViewersCreationWidget::nextButtonClicked() { + // check if at least an action has been created +#ifndef _WIZARD_QUESTIONS_SQUEEZE + if (createdViewers.isEmpty()) { + ui.requiredLabel->setStyleSheet(enhancedStyle); + ui.label_Star->setStyleSheet(enhancedStyle); + + // CCC Exception: Use a QMessageBox::warning instead of CAMITK_WARNING in the wizard + QMessageBox::warning(NULL, "Actions Creation Widget", "Please create at least one action in this ActionExtension\n"); + } + else { + ui.requiredLabel->setStyleSheet(normalStyle); + ui.label_Star->setStyleSheet(normalStyle); + emit next(); + } +#else + emit next(); +#endif +} + +void ViewersCreationWidget::registerDefaultViewerClicked() { + addViewerName("default"); +} + +void ViewersCreationWidget::registerNewViewerClicked() { + QString viewerName = QInputDialog::getText(this, "ViewerName", "Get a name to the New Viewer:"); + addViewerName(viewerName); +} + +void ViewersCreationWidget::previousButtonClicked() { + emit previous(); +} + +void ViewersCreationWidget::cancelButtonClicked() { + emit cancel(); +} + +void ViewersCreationWidget::setGroupBoxTitle(QString text) { + ui.viewersGroupBox->setTitle(text); +} + +void ViewersCreationWidget::emptyExistingViewers() { + createdViewers.clear(); + createdViewersString = defaultCreatedViewersString; + ui.createdViewersTextEdit->setHtml(createdViewersString); +} + +void ViewersCreationWidget::addViewerName(QString viewerName) { + this->createdViewers.append(viewerName); + + QString toBeInserted = "
  • " + viewerName + "
  • \n"; + int index = createdViewersString.lastIndexOf(""); + + createdViewersString.insert(index, toBeInserted); + ui.createdViewersTextEdit->setHtml(createdViewersString); +} \ No newline at end of file diff --git a/sdk/applications/wizard/ViewersCreationWidget.h b/sdk/applications/wizard/ViewersCreationWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..be1732892938a986cadae901aea1246cd26196c4 --- /dev/null +++ b/sdk/applications/wizard/ViewersCreationWidget.h @@ -0,0 +1,78 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#ifndef VIEWERSCREATIONWIDGET_H +#define VIEWERSCREATIONWIDGET_H + +// Include GUI automatically generated file +#include "ui_ViewersCreationWidget.h" + +// includes from Qt +#include +#include + +/** + * @ingroup group_sdk_application_wizard + * + * @brief + * Widget to create actions + * + */ +class ViewersCreationWidget : public QWidget { + + Q_OBJECT; + +public: + /** Constructor */ + ViewersCreationWidget(QWidget* parent); + + /** Destructor */ + ~ViewersCreationWidget() override = default; + + void setToDefault(); + + void setGroupBoxTitle(QString text); + void emptyExistingViewers(); + void addViewerName(QString viewerName); + +public slots: + virtual void registerDefaultViewerClicked(); + virtual void registerNewViewerClicked(); + virtual void nextButtonClicked(); + virtual void previousButtonClicked(); + virtual void cancelButtonClicked(); + +signals: + void next(); + void cancel(); + void previous(); + void newDefaultViewer(); + +private: + QStringList createdViewers; + QString createdViewersString; + + Ui::ViewersCreationWidget ui; +}; +#endif diff --git a/sdk/applications/wizard/ViewersCreationWidget.ui b/sdk/applications/wizard/ViewersCreationWidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..dc0e1e8d5e935e3f1440307002555d95fee228aa --- /dev/null +++ b/sdk/applications/wizard/ViewersCreationWidget.ui @@ -0,0 +1,720 @@ + + + ViewersCreationWidget + + + + 0 + 0 + 590 + 573 + + + + Form + + + + + + 3 + + + + + + + + 0 + 0 + + + + + Sans Serif + 8 + 50 + false + + + + Viewer-extension + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + Sans Serif + 9 + 75 + false + true + + + + Viewer(s) + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + Sans Serif + 8 + 50 + false + + + + Dependencies + + + Qt::AlignCenter + + + + + + + + Sans Serif + 8 + + + + Summary + + + Qt::AlignCenter + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + true + + + + 0 + 0 + + + + + 1 + 1 + + + + + 1 + 1 + + + + + Sans Serif + 8 + 50 + false + + + + 1 + + + Qt::AlignCenter + + + 0 + + + + + + + + 0 + 0 + + + + + 110 + 0 + + + + + 70 + 0 + + + + Qt::Horizontal + + + + + + + + Sans Serif + 9 + 75 + false + true + + + + 2 + + + Qt::AlignCenter + + + + + + + + 70 + 0 + + + + + 70 + 0 + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + 50 + false + + + + 3 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + + + + + Sans Serif + 8 + + + + 4 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 32 + 32 + + + + + 64 + 64 + + + + + + + :/resources/viewer_bas.png + + + true + + + + + + + + 14 + + + + <html><head/><body><p><span style=" font-weight:600;">Create your Viewers</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Viewers + + + + + + + + + + + + + + + + 0 + 0 + + + + + 550 + 32 + + + + + 16777215 + 32 + + + + Register Default Viewer + + + + :/resources/edit_add.png:/resources/edit_add.png + + + + + + + + 0 + 0 + + + + + 550 + 32 + + + + + 16777215 + 32 + + + + Register New Viewer + + + + :/resources/edit_add.png:/resources/edit_add.png + + + + + + + + + Arial + 10 + true + + + + * + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <html><head/><body><p>* Please, add at least an viewer in your extension</p></body></html> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 9 + + + + Previous + + + + :/resources/leftarrow.png:/resources/leftarrow.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 9 + + + + Cancel + + + + :/resources/button_cancel.png:/resources/button_cancel.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 64 + 32 + + + + + 128 + 32 + + + + + 9 + + + + Qt::RightToLeft + + + Next + + + + :/resources/rightarrow.png:/resources/rightarrow.png + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + registerDefaultViewerPushButton + clicked() + ViewersCreationWidget + registerDefaultViewerClicked() + + + 476 + 399 + + + 454 + 254 + + + + + registerNewViewerPushButton + clicked() + ViewersCreationWidget + registerNewViewerClicked() + + + 476 + 399 + + + 454 + 254 + + + + + nextPushButton + clicked() + ViewersCreationWidget + nextButtonClicked() + + + 577 + 560 + + + 711 + 579 + + + + + cancelPushButton + clicked() + ViewersCreationWidget + cancelButtonClicked() + + + 291 + 545 + + + 389 + 522 + + + + + previousPushButton + clicked() + ViewersCreationWidget + previousButtonClicked() + + + 73 + 546 + + + 141 + 519 + + + + + + registerDefaultViewerClicked() + registerNewViewerClicked() + nextButtonClicked() + cancelButtonClicked() + previousButtonClicked() + + diff --git a/sdk/applications/wizard/WizardController.cpp b/sdk/applications/wizard/WizardController.cpp index cc34d9ba04a2640e7d1d8580f60efdf1c5edfcf2..69e8b2d651448e5eced0c7eedb2975d3337a6092 100644 --- a/sdk/applications/wizard/WizardController.cpp +++ b/sdk/applications/wizard/WizardController.cpp @@ -53,6 +53,7 @@ #include "GeneratingCEPState.h" #include "ActionExtensionCreationState.h" +#include "ViewerExtensionCreationState.h" #include "ComponentExtensionCreationState.h" #include "LibraryCreationState.h" @@ -93,6 +94,9 @@ WizardController::WizardController() { // -------------------------- Action extensions ActionExtensionCreationState* actionExtensionCreationState = new ActionExtensionCreationState("Action Extension State", mainWindow, domCep); + // -------------------------- Viewer extensions + ViewerExtensionCreationState* viewerExtensionCreationState = new ViewerExtensionCreationState("Viewer Extension State", mainWindow, domCep); + // -------------------------- Component extensions ComponentExtensionCreationState* componentExtensionCreationState = new ComponentExtensionCreationState("Component Extension State", mainWindow, domCep); // -------------------------- Libraries @@ -116,6 +120,7 @@ WizardController::WizardController() { machine.addState(cepCreateRecapState); machine.addState(actionExtensionCreationState); + machine.addState(viewerExtensionCreationState); machine.addState(componentExtensionCreationState); machine.addState(libraryCreationState); @@ -148,6 +153,9 @@ WizardController::WizardController() { cepCreateRecapState->addTransition(cepCreateRecapWidget, SIGNAL(addActionExtension()), actionExtensionCreationState); actionExtensionCreationState->addTransition(actionExtensionCreationState, SIGNAL(next()), cepCreateRecapState); + cepCreateRecapState->addTransition(cepCreateRecapWidget, SIGNAL(addViewerExtension()), viewerExtensionCreationState); + viewerExtensionCreationState->addTransition(viewerExtensionCreationState, SIGNAL(next()), cepCreateRecapState); + cepCreateRecapState->addTransition(cepCreateRecapWidget, SIGNAL(addComponentExtension()), componentExtensionCreationState); componentExtensionCreationState->addTransition(componentExtensionCreationState, SIGNAL(next()), cepCreateRecapState); diff --git a/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake b/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake index f946f7e7b88b136eb301332c1a7d3e5c7cff4dbe..41ac104993bb39d11edf59bae5d0a3367286735e 100644 --- a/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake +++ b/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake @@ -217,9 +217,9 @@ macro(camitk_extension) ######################################################################### # BASIC DIRECTORIES - include_directories(${CAMITK_INCLUDE_DIRECTORIES}) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + include_directories(${CAMITK_INCLUDE_DIRECTORIES}) # USER INPUT DIRECTORIES include_directories(${${EXTENSION_NAME_CMAKE}_INCLUDE_DIRECTORIES}) diff --git a/sdk/libraries/cepgenerator/CepGenerator.cpp b/sdk/libraries/cepgenerator/CepGenerator.cpp index 4c0a3f0405608eb1c4808cb73d159895af655f80..0738fe94c01e8f94bc38a3555e7098e7537140f5 100644 --- a/sdk/libraries/cepgenerator/CepGenerator.cpp +++ b/sdk/libraries/cepgenerator/CepGenerator.cpp @@ -451,6 +451,26 @@ void CepGenerator::createComponentExtensionDoms() { } } +void CepGenerator::createViewerExtensionDoms() { + std::cout << "creating viewer extension doms..." << std::endl; + QString cmakelistFileName; + QDir currentDirectory; + currentDirectory.cd(devDirectoryName.absolutePath()); + currentDirectory.cd(cepDirectoryName); + currentDirectory.cd(cepViewersDirectoryName); + + if (domCep->viewerExtensions().present()) { + ViewerExtensions extensions = domCep->viewerExtensions().get(); + for (auto i = extensions.viewerExtension().begin(); i != extensions.viewerExtension().end(); i++) { + // TODO: find a way to use std:auto_ptr here for the dom extension instead of creating a new instance + // Is it only possible ? http://stackoverflow.com/questions/12674735/function-wont-accept-iterator-to-auto-ptr + ViewerExtension& extension = (*i); + ViewerExtensionGenerator* generator = new ViewerExtensionGenerator(extension, currentDirectory.absolutePath(), licence); + this->extensions.append(generator); + } + } +} + void CepGenerator::createLibrarieDoms() { std::cout << "creating library doms..." << std::endl; QDir currentDirectory; @@ -471,26 +491,6 @@ void CepGenerator::createLibrarieDoms() { } -void CepGenerator::createViewersExtensionDoms() { - std::cout << "creating viewer extension doms..." << std::endl; - QString cmakelistFileName; - QDir currentDirectory; - currentDirectory.cd(devDirectoryName.absolutePath()); - currentDirectory.cd(cepDirectoryName); - currentDirectory.cd(cepViewersDirectoryName); - - if (domCep->viewerExtensions().present()) { - ViewerExtensions extensions = domCep->viewerExtensions().get(); - for (auto i = extensions.viewerExtension().begin(); i != extensions.viewerExtension().end(); i++) { - // TODO: find a way to use std:auto_ptr here for the dom extension instead of creating a new instance - // Is it only possible ? http://stackoverflow.com/questions/12674735/function-wont-accept-iterator-to-auto-ptr - ViewerExtension& extension = (*i); - ViewerExtensionGenerator* generator = new ViewerExtensionGenerator(extension, currentDirectory.absolutePath(), licence); - this->extensions.append(generator); - } - } -} - void CepGenerator::generateExtensions() { std::cout << "inside generateExtension" << std::endl; @@ -507,6 +507,6 @@ void CepGenerator::process() { createComponentExtensionDoms(); createActionExtensionDoms(); createLibrarieDoms(); - createViewersExtensionDoms(); + createViewerExtensionDoms(); generateExtensions(); } diff --git a/sdk/libraries/cepgenerator/CepGenerator.h b/sdk/libraries/cepgenerator/CepGenerator.h index 9a843d8d65c075b05c4aca700a54ec8ef6ce8145..b43b9eef8da56f79e3c87e81244e9ea3d8e69242 100644 --- a/sdk/libraries/cepgenerator/CepGenerator.h +++ b/sdk/libraries/cepgenerator/CepGenerator.h @@ -177,15 +177,15 @@ protected: */ virtual void createComponentExtensionDoms(); + /** + Create the ViewersDom if needed and call the appropriate methods to generate the viewer extensions. + */ + virtual void createViewerExtensionDoms(); + /** Create the LibrariesDom if needed and call the appropriate methods to generate the libraries. */ virtual void createLibrarieDoms(); - - /** - Create the ViewersDom if needed and call the appropriate methods to generate the viewer extensions. - */ - virtual void createViewersExtensionDoms(); virtual void generateExtensions();