Skip to content
28 changes: 23 additions & 5 deletions applications/mne_scan/libs/scShared/Plugins/abstractalgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,15 @@ class AbstractAlgorithm : public AbstractPlugin

//=========================================================================================================
/**
* Returns the set up widget for configuration of AbstractAlgorithm.
* Pure virtual method inherited by AbstractPlugin.
*
* @return the setup widget.
* Returns whether a plugin has a GUI component.
*/
virtual inline bool hasGUI() const;

//=========================================================================================================
/**
* Whether the plugin can be added to a scene.
*/
virtual QWidget* setupWidget() = 0; //setup();
virtual bool inline isScenePlugin() const;

protected:
//=========================================================================================================
Expand All @@ -161,6 +164,21 @@ inline bool AbstractAlgorithm::multiInstanceAllowed() const
{
return true;
}

//=============================================================================================================

inline bool AbstractAlgorithm::hasGUI() const
{
return true;
}

//=============================================================================================================

inline bool AbstractAlgorithm::isScenePlugin() const
{
return true;
}

} // NAMESPACE

Q_DECLARE_INTERFACE(SCSHAREDLIB::AbstractAlgorithm, "scsharedlib/1.0")
Expand Down
4 changes: 4 additions & 0 deletions applications/mne_scan/libs/scShared/Plugins/abstractpassive.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef ABSTRACTPASSIVE_H
#define ABSTRACTPASSIVE_H

#endif // ABSTRACTPASSIVE_H
42 changes: 13 additions & 29 deletions applications/mne_scan/libs/scShared/Plugins/abstractplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@

#include "../scshared_global.h"

#include "plugingui.h"

#include "../Management/pluginoutputdata.h"
#include "../Management/plugininputdata.h"

#include <disp/viewers/abstractview.h>

#include <memory>

//=============================================================================================================
// QT INCLUDES
//=============================================================================================================
Expand Down Expand Up @@ -142,11 +146,9 @@ class SCSHAREDSHARED_EXPORT AbstractPlugin : public QThread

//=========================================================================================================
/**
* A list of actions for the current plugin.
*
* @return a list of plugin actions.
* Whether the plugin can be added to a scene.
*/
inline QList< QAction* > getPluginActions();
virtual bool isScenePlugin() const = 0;

//=========================================================================================================
/**
Expand All @@ -172,16 +174,13 @@ class SCSHAREDSHARED_EXPORT AbstractPlugin : public QThread
*
* @return true if multi instantiation of plugin is allowed.
*/
virtual inline bool multiInstanceAllowed() const = 0;
virtual inline bool multiInstanceAllowed() const;

//=========================================================================================================
/**
* Returns the set up widget for configuration of the AbstractPlugin.
* Pure virtual method.
*
* @return the setup widget.
* Returns whether a plugin has a GUI component.
*/
virtual QWidget* setupWidget() = 0; //setup()
virtual bool hasGUI() const = 0;

//=========================================================================================================
/**
Expand All @@ -194,6 +193,7 @@ class SCSHAREDSHARED_EXPORT AbstractPlugin : public QThread
inline InputConnectorList& getInputConnectors(){return m_inputConnectors;}
inline OutputConnectorList& getOutputConnectors(){return m_outputConnectors;}

inline const PluginGUI* getGUI() const;
signals:
//=========================================================================================================
/**
Expand Down Expand Up @@ -223,21 +223,12 @@ class SCSHAREDSHARED_EXPORT AbstractPlugin : public QThread
*/
virtual void run() = 0;

//=========================================================================================================
/**
* Adds a plugin action to the current plugin.
*
* @param[in] pAction pointer to the action to be added to the plugin.
*/
inline void addPluginAction(QAction* pAction);

InputConnectorList m_inputConnectors; /**< Set of input connectors associated with this plug-in. */
OutputConnectorList m_outputConnectors; /**< Set of output connectors associated with this plug-in. */

bool m_bPluginControlWidgetsInit = false; /**< Flag to indicate if the plugin control widgets were initialized already. */

private:
QList< QAction* > m_qListPluginActions; /**< List of plugin actions. */
std::unique_ptr<PluginGUI> m_pGUI; /**< Plugin GUI. */
};

//=============================================================================================================
Expand All @@ -251,16 +242,9 @@ inline bool AbstractPlugin::multiInstanceAllowed() const

//=============================================================================================================

inline QList< QAction* > AbstractPlugin::getPluginActions()
{
return m_qListPluginActions;
}

//=============================================================================================================

inline void AbstractPlugin::addPluginAction(QAction* pAction)
inline const PluginGUI* AbstractPlugin::getGUI() const
{
m_qListPluginActions.append(pAction);
return m_pGUI.get();
}

//=============================================================================================================
Expand Down
28 changes: 23 additions & 5 deletions applications/mne_scan/libs/scShared/Plugins/abstractsensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,15 @@ class AbstractSensor : public AbstractPlugin

//=========================================================================================================
/**
* Returns the set up widget for configuration of AbstractSensor.
* Pure virtual method inherited by IModule.
*
* @return the setup widget.
* Returns whether a plugin has a GUI component.
*/
virtual QWidget* setupWidget() = 0;
virtual inline bool hasGUI() const;

//=========================================================================================================
/**
* Whether the plugin can be added to a scene.
*/
virtual bool inline isScenePlugin() const;

protected:

Expand All @@ -154,6 +157,21 @@ inline bool AbstractSensor::multiInstanceAllowed() const
{
return false;
}

//=============================================================================================================

inline bool AbstractSensor::hasGUI() const
{
return true;
}

//=============================================================================================================

inline bool AbstractSensor::isScenePlugin() const
{
return true;
}

} //NAMESPACE

Q_DECLARE_INTERFACE(SCSHAREDLIB::AbstractSensor, "scsharedlib/1.0")
Expand Down
155 changes: 155 additions & 0 deletions applications/mne_scan/libs/scShared/Plugins/plugingui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#ifndef PLUGINGUI_H
#define PLUGINGUI_H

//=============================================================================================================
// QT INCLUDES
//=============================================================================================================

#include <QAction>
#include <QMenu>
#include <QWidget>

//=============================================================================================================
/**
* Used as the interface for returning the GUI for a plugin.
*
* Can be used by either passing in items with the 'add' and 'set' functions,
* or subclassed and reimplementing the 'get' functions.
*/
class PluginGUI
{
public:
//=========================================================================================================
/**
* A list of actions for the current plugin.
*
* @return a list of plugin actions.
*/
inline virtual QList< QAction* > getPluginActions() const;

//=========================================================================================================
/**
* A list of menus for the current plugin.
*
* @return a list of plugin actions.
*/
inline virtual QList< QMenu* > getPluginMenus() const;

//=========================================================================================================
/**
* A list of widgets for the current plugin.
*
* @return a list of plugin actions.
*/
inline virtual QList< QWidget* > getPluginWidgets() const;

//=========================================================================================================
/**
* Adds a plugin action to the current plugin.
*
* @param[in] pAction pointer to the action to be added to the plugin.
*/
inline void addPluginAction(QAction* pAction);

//=========================================================================================================
/**
* Adds a plugin menu to the current plugin.
*
* @param[in] pMenu pointer to the menu to be added to the plugin.
*/
inline void addPluginMenu(QMenu* pMenu);

//=========================================================================================================
/**
* Adds a plugin widget to the current plugin.
*
* @param[in] pWidget pointer to the widget to be added to the plugin.
*/
inline void addPluginWidget(QWidget* pWidget);

//=========================================================================================================
/**
* Returns the set up widget for configuration of the AbstractPlugin.
*
* @return the setup widget.
*/
inline virtual QWidget* getSetupWidget() const;

//=========================================================================================================
/**
* Sets the setup widget.
*/
inline void setSetupWidget(QWidget* pWidget);


private:
QList< QAction* > m_qListPluginActions; /**< List of plugin actions. */
QList< QMenu* > m_qListPluginMenus; /**< List of plugin menus. */
QList< QWidget* > m_qListPluginWidgets; /**< List of plugin widgets. */

QWidget* m_pSetupWidget;
};

//=============================================================================================================
// INLINE DEFINITIONS
//=============================================================================================================


inline QList< QAction* > PluginGUI::getPluginActions() const
{
return m_qListPluginActions;
}

//=============================================================================================================

inline void PluginGUI::addPluginAction(QAction* pAction)
{
m_qListPluginActions.append(pAction);
}

//=============================================================================================================

inline QList< QMenu* > PluginGUI::getPluginMenus() const
{
return m_qListPluginMenus;
}

//=============================================================================================================

inline void PluginGUI::addPluginMenu(QMenu* pMenu)
{
m_qListPluginMenus.append(pMenu);
}

//=============================================================================================================

inline QList< QWidget* > PluginGUI::getPluginWidgets() const
{
return m_qListPluginWidgets;
}

//=============================================================================================================

inline void PluginGUI::addPluginWidget(QWidget* pWidget)
{
m_qListPluginWidgets.append(pWidget);
}

//=============================================================================================================

inline QWidget* PluginGUI::getSetupWidget() const
{
return m_pSetupWidget;
}

//=============================================================================================================
/**
* Sets the setup widget.
*/
inline void PluginGUI::setSetupWidget(QWidget* pWidget)
{
m_pSetupWidget = pWidget;
}


#endif // PLUGINGUI_H
2 changes: 2 additions & 0 deletions applications/mne_scan/libs/scShared/scShared.pro
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ SOURCES += \
Management/displaymanager.cpp

HEADERS += \
Plugins/abstractpassive.h \
Plugins/plugingui.h \
scshared_global.h \
Plugins/abstractplugin.h \
Plugins/abstractsensor.h \
Expand Down
Loading