28#ifndef ADDININTERFACE_H
29#define ADDININTERFACE_H
31#include "commonGlobal.h"
33#include "apiFunctionsInc.h"
34#include "apiFunctionsGraphInc.h"
36#include "addInInterfaceVersion.h"
37#include "sharedStructuresQt.h"
38#include "sharedStructures.h"
39#include "functionCancellationAndObserver.h"
46#include <qsharedpointer.h>
48#include <qapplication.h>
49#include <qscopedpointer.h>
50#include <QtWidgets/qdockwidget.h>
53#if defined _DEBUG && defined(_MSC_VER) && defined(VISUAL_LEAK_DETECTOR_CMAKE)
63#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC)
70#define NEW_PLUGININSTANCE(PluginClass) \
71 PluginClass* newInst = new PluginClass(); \
72 newInst->setBasePlugin(this); \
73 *addInInst = qobject_cast<ito::AddInBase*>(newInst); \
74 m_InstList.append(*addInInst);
82#define REMOVE_PLUGININSTANCE(PluginClass) \
85 (*addInInst)->deleteLater(); \
86 m_InstList.removeOne(*addInInst); \
94#define REGISTER_FILTERS_AND_WIDGETS \
95 foreach(ito::AddInAlgo::FilterDef *f, newInst->m_filterList) \
97 f->m_pBasePlugin = this; \
99 foreach(ito::AddInAlgo::AlgoWidgetDef *w, newInst->m_algoWidgetList) \
101 w->m_pBasePlugin = this; \
105#define PLUGIN_ITOM_API \
107 void importItomApi(void** apiPtr) \
108 {ito::ITOM_API_FUNCS = apiPtr;} \
109 void importItomApiGraph(void** apiPtr) \
110 { ito::ITOM_API_FUNCS_GRAPH = apiPtr;} \
112 virtual int getAddInInterfaceVersion() const \
113 { return ITOM_ADDININTERFACE_VERSION; } \
171 actuatorError = 0x10000,
211 QVector<Param> paramsMand;
212 QVector<Param> paramsOpt;
213 QVector<Param> paramsOut;
256 QScopedPointer<AddInInterfaceBasePrivate> d_ptr;
278 virtual void importItomApi(
void** apiPtr) = 0;
279 virtual void importItomApiGraph(
void** apiPtr) = 0;
284 if (qobject_cast<QApplication*>(QCoreApplication::instance()))
295 void **m_apiFunctionsBasePtr;
296 void **m_apiFunctionsGraphBasePtr;
311 inline int getType(
void)
const {
return m_type; }
329 const QString
getAuthor(
void)
const {
return m_author; }
343 inline QList<ito::AddInBase *>
getInstList(
void) {
return m_InstList; }
344 inline const QList<ito::AddInBase *> getInstList(
void)
const {
return m_InstList; }
362 void setApiFunctions(
void **apiFunctions);
365 void setLoader(QPluginLoader *loader);
366 QPluginLoader * getLoader(
void)
const;
368 bool event(QEvent *e);
393 AddInRef(
void *p,
int t) : type(t), ptr(p) {}
399 const Param getParamRec(
const QString name,
bool *nameCheckOk = NULL)
const;
431 virtual int hasConfDialog(
void);
437 int createdByGUI()
const;
440 void setCreatedByGUI(
int value);
446 int getRefCount(
void)
const;
452 bool hasDockWidget(
void)
const;
458 QDockWidget* getDockWidget(
void)
const;
461 virtual void dockWidgetDefaultStyle(
bool &floating,
bool &visible, Qt::DockWidgetArea &defaultArea)
const;
483 bool isInitialized(
void)
const;
489 void setInitialized(
bool initialized);
499 QVector<ito::AddInBase::AddInRef *> *
getArgAddIns(
void) {
return &m_hwDecList; }
513 QMutex& getUserMutex();
515 static int getMaximumThreadCount();
517 static RetVal setMaximumThreadCount(
int threadCount);
527 void setIdentifier(
const QString &identifier);
530 void createDockWidget(QString title, QDockWidget::DockWidgetFeatures features, Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas, QWidget *content = NULL);
533 ito::RetVal registerExecFunc(
const QString funcName,
const QVector<ito::Param> ¶msMand,
const QVector<ito::Param> ¶msOpt,
const QVector<ito::Param> ¶msOut,
const QString infoString);
545 if (qobject_cast<QApplication*>(QCoreApplication::instance()))
559 void incRefCount(
void);
562 void decRefCount(
void);
567 QScopedPointer<AddInBasePrivate> d_ptr;
572 static int m_instCounter;
605 virtual ito::RetVal execFunc(
const QString funcName, QSharedPointer<QVector<ito::ParamBase> > paramsMand, QSharedPointer<QVector<ito::ParamBase> > paramsOpt, QSharedPointer<QVector<ito::ParamBase> > paramsOut,
ItomSharedSemaphore *waitCond = NULL);
668 QScopedPointer<AddInDataIOPrivate> d_ptr;
675 void runStatusChanged(
bool deviceStarted);
745 QScopedPointer<AddInActuatorPrivate> d_ptr;
757 bool isMotorMoving()
const;
759 void sendStatusUpdate(
const bool statusOnly =
false);
760 void sendTargetUpdate();
767 virtual ito::RetVal waitForDone(
const int timeoutMS = -1,
const QVector<int> axis = QVector<int>() ,
const int flags = 0 ) = 0;
780 void setStatus(
int &status,
const int newFlags,
const int keepMask = 0);
793 void setStatus(
const QVector<int> &axis,
const int newFlags,
const int keepMask = 0);
805 void replaceStatus(
int &status,
const int existingFlag,
const int replaceFlag);
818 void replaceStatus(
const QVector<int> &axis,
const int existingFlag,
const int replaceFlag);
825 void initStatusAndPositions(
int numAxes,
int status,
double currentPosition = 0.0,
double targetPosition = 0.0,
bool sendUpdateSignals =
true);
834 bool isInterrupted();
853 void resetInterrupt();
864 ito::RetVal getLastSignalledStates(QVector<int> &status, QVector<double> ¤tPos, QVector<double> &targetPos);
917 virtual ito::RetVal requestStatusAndPosition(
bool sendCurrentPos,
bool sendTargetPos);
936 QScopedPointer<AddInAlgoPrivate> d_ptr;
940 typedef ito::RetVal (*t_filter) (QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, QVector<ito::ParamBase> *paramsOut);
941 typedef ito::RetVal (*t_filterExt) (QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, QVector<ito::ParamBase> *paramsOut, QSharedPointer<ito::FunctionCancellationAndObserver> observer);
942 typedef QWidget* (*t_algoWidget) (QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt,
ito::RetVal &retValue);
943 typedef ito::RetVal (*t_filterParam)(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut);
950 catAnalyseDataObject = 0x0002,
951 catPlotDataObject = 0x0004
957 iNotSpecified = 0x0000,
958 iReadDataObject = 0x0001,
959 iWriteDataObject = 0x0002,
960 iReadPointCloud = 0x0004,
961 iWritePointCloud = 0x0008,
962 iReadPolygonMesh = 0x0010,
963 iWritePolygonMesh = 0x0020,
964 iPlotSingleObject = 0x0040
969 Q_ENUM(tAlgoCategory)
970 Q_ENUM(tAlgoInterface)
986 FilterDef(AddInAlgo::t_filter filterFunc, AddInAlgo::t_filterParam filterParamFunc,
989 QString interfaceMeta = QString()) :
990 m_filterFunc(filterFunc),
991 m_paramFunc(filterParamFunc),
993 m_description(description),
994 m_category(category),
996 m_interfaceMeta(interfaceMeta)
999 virtual ~FilterDef() {}
1020 m_filterFuncExt(NULL)
1024 FilterDefExt(AddInAlgo::t_filterExt filterFuncExt, AddInAlgo::t_filterParam filterParamFunc,
1027 QString interfaceMeta = QString(),
bool hasStatusInfo =
true,
bool isCancellable =
true) :
1028 FilterDef(NULL, filterParamFunc, description, category, interf, interfaceMeta),
1029 m_filterFuncExt(filterFuncExt),
1030 m_hasStatusInformation(hasStatusInfo),
1031 m_isCancellable(isCancellable)
1034 virtual ~FilterDefExt() {}
1052 m_pBasePlugin(NULL),
1059 m_widgetFunc(algoWidgetFunc),
1060 m_paramFunc(algoWidgetParamFunc),
1061 m_pBasePlugin(NULL),
1062 m_description(description),
1063 m_category(category),
1064 m_interface(interf),
1065 m_interfaceMeta(interfaceMeta)
1083 ito::RetVal getFilterList(QHash<QString, FilterDef *> &fList)
const;
1084 ito::RetVal getAlgoWidgetList(QHash<QString, AlgoWidgetDef *> &awList)
const;
1086 ito::RetVal rejectAlgoWidget(
const QString &name);
1091 QHash<QString, FilterDef *> m_filterList;
1092 QHash<QString, AlgoWidgetDef *> m_algoWidgetList;
1095 static ito::RetVal prepareParamVectors(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut);
semaphore which can be used for asynchronous thread communication. By using this class it is possible...
Definition sharedStructuresQt.h:58
base class for all actuator plugin classes
Definition addInInterface.h:739
Q_DECLARE_PRIVATE(AddInActuator)
virtual ito::RetVal setOrigin(const int axis, ItomSharedSemaphore *waitCond=NULL)=0
method to set the origin of one axis to the current position
virtual ito::RetVal setPosAbs(const QVector< int > axis, QVector< double > pos, ItomSharedSemaphore *waitCond=NULL)=0
move a number of axis to a new absolute position. The axis' numbers are given in the axis vector
void actuatorStatusChanged(QVector< int > status, QVector< double > actPosition)
signal emitted if status or actual position of any axis has been changed.
virtual ito::RetVal calib(const int axis, ItomSharedSemaphore *waitCond=NULL)=0
method to calibrate a single axis
virtual ito::RetVal getStatus(QSharedPointer< QVector< int > > status, ItomSharedSemaphore *waitCond)=0
retrieve the status of the actuator
virtual ito::RetVal setPosAbs(const int axis, const double pos, ItomSharedSemaphore *waitCond=NULL)=0
move a single axis to a new absolute position
virtual ito::RetVal getPos(const QVector< int > axis, QSharedPointer< QVector< double > > pos, ItomSharedSemaphore *waitCond)=0
read the position of a number of axis. The axis' numbers are given in the axis vector
virtual ito::RetVal calib(const QVector< int > axis, ItomSharedSemaphore *waitCond=NULL)=0
method to calibrate a number of axis. The axis' numbers are given in the axis vector
virtual ito::RetVal setPosRel(const int axis, const double pos, ItomSharedSemaphore *waitCond=NULL)=0
increment/decrement a single axis by position value
void targetChanged(QVector< double > targetPositions)
signal emitted if target position of any axis has changed.
QVector< double > m_currentPos
Definition addInInterface.h:753
QVector< double > m_targetPos
Definition addInInterface.h:754
QVector< int > m_currentStatus
Definition addInInterface.h:752
virtual ito::RetVal setPosRel(const QVector< int > axis, QVector< double > pos, ItomSharedSemaphore *waitCond=NULL)=0
increment/decrement a number of axis by position values. The axis' numbers are given in the axis vect...
virtual ito::RetVal waitForDone(const int timeoutMS=-1, const QVector< int > axis=QVector< int >(), const int flags=0)=0
this method must be overwritten.
virtual ito::RetVal getPos(const int axis, QSharedPointer< double > pos, ItomSharedSemaphore *waitCond)=0
read the position of one axis
virtual ito::RetVal setOrigin(const QVector< int > axis, ItomSharedSemaphore *waitCond=NULL)=0
method to set the origin of a number of axis to their current positions. The axis' numbers are given ...
Definition addInInterface.cpp:1186
extended FilterDef (derived from FilterDef) with a filterFunc of type f_filterExt instead of t_filter...
Definition addInInterface.h:1015
bool m_hasStatusInformation
true, if filter updates status information to the optional observer
Definition addInInterface.h:1037
bool m_isCancellable
true, if filter listens to a possible interrupt flag in the optional observer and cancels the executi...
Definition addInInterface.h:1038
FilterDefExt()
< empty, default constructor
Definition addInInterface.h:1018
t_filterExt m_filterFuncExt
extended function pointer (unbounded, static) for filter-method
Definition addInInterface.h:1036
container for publishing filters provided by any plugin
Definition addInInterface.h:974
ito::AddInAlgo::tAlgoCategory m_category
category, filter belongs to (default: catNone)
Definition addInInterface.h:1006
FilterDef()
< empty, default constructor
Definition addInInterface.h:977
QString m_description
description of filter
Definition addInInterface.h:1005
t_filter m_filterFunc
function pointer (unbounded, static) for filter-method
Definition addInInterface.h:1001
ito::AddInAlgo::tAlgoInterface m_interface
algorithm interface, filter fits to (default: iNotSpecified)
Definition addInInterface.h:1007
QString m_name
name of filter
Definition addInInterface.h:1004
QString m_interfaceMeta
meta information if required by algorithm interface
Definition addInInterface.h:1008
ito::AddInInterfaceBase * m_pBasePlugin
interface (factory) instance of this plugin (will be automatically filled)
Definition addInInterface.h:1003
t_filterParam m_paramFunc
function pointer (unbounded, static) for filter's default parameter method
Definition addInInterface.h:1002
base class for all "algorithm" plugin classes
Definition addInInterface.h:930
tAlgoCategory
Definition addInInterface.h:947
@ catNone
default: no category
Definition addInInterface.h:948
tAlgoInterface
Definition addInInterface.h:956
@ iNotSpecified
default: filter or widget does not fit to any interface
Definition addInInterface.h:957
Q_DECLARE_PRIVATE(AddInAlgo)
Definition addInInterface.cpp:1443
Base class for all plugins.
Definition addInInterface.h:386
virtual ito::RetVal setParam(QSharedPointer< ito::ParamBase > val, ItomSharedSemaphore *waitCond=NULL)=0
method to set a parameter. The actual value is always passed as ito::ParamBase (must be overwritten)....
const ito::RetVal getExecFuncList(QMap< QString, ExecFuncParams > **funcs)
returns list of registered additional functions
Definition addInInterface.h:422
QMap< QString, Param > m_params
map of the available parameters
Definition addInInterface.h:538
QString m_identifier
unique identifier (serial number, com-port...)
Definition addInInterface.h:540
Q_DECLARE_PRIVATE(AddInBase)
virtual ito::RetVal getParam(QSharedPointer< ito::Param > val, ItomSharedSemaphore *waitCond=NULL)=0
method for the retrieval of a parameter. The actual value is always passed as ito::Param (must be ove...
void parametersChanged(QMap< QString, ito::Param > params)
This signal usually is emitted if the vector m_params is changed.
QMap< QString, ExecFuncParams > m_execFuncList
map with registered additional functions. funcExec-name -> (default mandParams, default optParams,...
Definition addInInterface.h:565
void sendParameterRequest()
immediately emits the signal parametersChanged
Definition addInInterface.h:618
const ito::RetVal getParamList(QMap< QString, Param > **paramNames)
returns a map with the parameters of this plugin.
Definition addInInterface.h:414
QString getIdentifier() const
retrieve the unique identifier of this instance
Definition addInInterface.h:428
QVector< ito::AddInBase::AddInRef * > m_hwDecList
list of hardware that was passed to the plugin on initialisation and whose refcounter was incremented
Definition addInInterface.h:564
virtual ito::RetVal close(ItomSharedSemaphore *waitCond)=0
method for closing an instance (must be overwritten)
virtual ito::RetVal init(QVector< ito::ParamBase > *paramsMand, QVector< ito::ParamBase > *paramsOpt, ItomSharedSemaphore *waitCond=NULL)=0
method for the initialisation of a new instance of the class (must be overwritten)
static int maxThreadCount
maximum number of threads algorithms can use e.g. with OpenMP parallelization. This is a number betwe...
Definition addInInterface.h:573
bool hasGuiSupport()
check if we have gui support
Definition addInInterface.h:543
QVector< ito::AddInBase::AddInRef * > * getArgAddIns(void)
returns vector of AddInRef instances.
Definition addInInterface.h:499
virtual void dockWidgetVisibilityChanged(bool)
overwrite this slot if you want to get informed when the dock-widget of the plugin becomes (in)visibl...
Definition addInInterface.h:631
Definition addInInterface.cpp:169
base class for all dataIO plugin classes
Definition addInInterface.h:662
bool m_autoGrabbingEnabled
Definition addInInterface.h:682
Q_DECLARE_PRIVATE(AddInDataIO)
QSet< QObject * > m_autoGrabbingListeners
Definition addInInterface.h:679
int getAutoGrabbing()
Definition addInInterface.h:685
int m_timerID
Definition addInInterface.h:680
int m_timerIntervalMS
Definition addInInterface.h:681
Definition addInInterface.cpp:817
forward declaration to private container class of AddInAlog
Definition addInInterface.h:249
tAutoLoadPolicy m_autoLoadPolicy
Definition addInInterface.h:273
int getMaxItomVer(void) const
returns maximum supported version of main program
Definition addInInterface.h:317
int getInstCount()
get number instantiated plugins
Definition addInInterface.h:360
int m_minItomVer
maximum supported version of the main program
Definition addInInterface.h:263
const QString getAboutInfo(void) const
returns a detailed description of the plugin compile information
Definition addInInterface.h:337
bool hasGuiSupport()
Definition addInInterface.h:282
const QString getLicenseInfo(void) const
returns a detailed description of the plugin license
Definition addInInterface.h:335
Q_DECLARE_PRIVATE(AddInInterfaceBase)
virtual QVector< ito::Param > * getInitParamsOpt(void)
returns a vector with the optional initialisation parameters
Definition addInInterface.h:350
int getVersion(void) const
returns addIn version
Definition addInInterface.h:313
const QString getDetailDescription(void) const
returns a detailed description of the plugin
Definition addInInterface.h:333
QVector< ito::Param > m_initParamsOpt
vector with the optional initialisation parameters, please only read this vector within the init-meth...
Definition addInInterface.h:272
int getMinItomVer(void) const
returns minimum required version of main program
Definition addInInterface.h:315
QList< ito::AddInBase * > m_InstList
vector holding a list of the actual instantiated classes of the plugin
Definition addInInterface.h:270
virtual ito::RetVal closeThisInst(ito::AddInBase **addInInst)=0
< internal function used within the closing process
QString m_filename
plugin (library) filename on the disc
Definition addInInterface.h:264
QString m_description
a brief description of the plugin
Definition addInInterface.h:266
int getType(void) const
returns addIn type
Definition addInInterface.h:311
virtual QVector< ito::Param > * getInitParamsMand(void)
returns a vector with the mandatory initialisation parameters
Definition addInInterface.h:348
tAutoLoadPolicy getAutoLoadPolicy(void) const
returns true if the plugin allows his own parameter load to be autoloaded by addin manager
Definition addInInterface.h:323
const QString getAuthor(void) const
returns plugin author
Definition addInInterface.h:329
virtual int getAddInInterfaceVersion() const =0
pure virtual function that returns the addin interface version of the plugin
const QString getDescription(void) const
returns a brief description of the plugin
Definition addInInterface.h:331
bool m_callInitInNewThread
Definition addInInterface.h:275
QString m_detaildescription
a detail description of the plugin
Definition addInInterface.h:267
virtual ito::RetVal getAddInInst(ito::AddInBase **addInInst)=0
method to instantiate a new class of the plugin
QString m_author
the plugin author
Definition addInInterface.h:265
QString m_license
a short license string for the plugin, default value is "LGPL with ITO itom-exception"
Definition addInInterface.h:268
QList< ito::AddInBase * > getInstList(void)
returns a list of the actual instantiated classes from this plugin
Definition addInInterface.h:343
int m_version
plugin version
Definition addInInterface.h:261
int m_type
plugin type
Definition addInInterface.h:260
tAutoSavePolicy getAutoSavePolicy(void) const
returns true if the plugin allows his own parameter save to be autoloaded by addin manager
Definition addInInterface.h:326
tAutoSavePolicy m_autoSavePolicy
Definition addInInterface.h:274
bool getCallInitInNewThread(void) const
returns whether init-method should be called in new thread (default) or still in main thread
Definition addInInterface.h:320
QVector< ito::Param > m_initParamsMand
vector with the mandatory initialisation parameters, please only read this vector within the init-met...
Definition addInInterface.h:271
const QString getFilename(void) const
returns the plugin's filename
Definition addInInterface.h:339
int m_maxItomVer
minimum required version of the main program
Definition addInInterface.h:262
Definition addInInterface.cpp:52
dataObject contains a n-dimensional matrix
Definition dataobj.h:591
class for parameter handling e.g. to pass parameters to plugins
Definition param.h:477
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.h:39
Definition apiFunctionsGraph.cpp:40
PyObject * setParam(ito::AddInBase *addInObj, PyObject *args)
Definition pythonPlugins.cpp:1249
tAutoLoadPolicy
Definition addInInterface.h:188
@ autoLoadKeywordDefined
Definition addInInterface.h:191
@ autoLoadAlways
Definition addInInterface.h:189
@ autoLoadNever
Definition addInInterface.h:190
tPluginType
tPluginType enumeration
Definition addInInterface.h:129
@ typeDataIO
Definition addInInterface.h:130
@ typeActuator
Definition addInInterface.h:131
@ typeAlgo
Definition addInInterface.h:132
@ typeADDA
Definition addInInterface.h:134
@ typeRawIO
Definition addInInterface.h:135
@ typeGrabber
Definition addInInterface.h:133
PyObject * getParam(ito::AddInBase *addInObj, PyObject *args)
Definition pythonPlugins.cpp:770
tAutoSavePolicy
Definition addInInterface.h:195
@ autoSaveNever
Definition addInInterface.h:197
@ autoSaveAlways
Definition addInInterface.h:196
tActuatorStatus
tActuatorStatus enumeration
Definition addInInterface.h:149
@ actMovingMask
Definition addInInterface.h:173
@ actEndSwitchMask
Definition addInInterface.h:175
@ actStatusMask
Definition addInInterface.h:184
@ actuatorMoving
Definition addInInterface.h:153
@ actuatorRightEndSwitch
Definition addInInterface.h:159
@ actuatorUnknown
Definition addInInterface.h:151
@ actuatorAvailable
Definition addInInterface.h:169
@ actuatorRefSwitch2
Definition addInInterface.h:166
@ actuatorLeftEndSwitch
Definition addInInterface.h:158
@ actuatorEndSwitch2
Definition addInInterface.h:161
@ actuatorEnabled
Definition addInInterface.h:170
@ actuatorTimeout
Definition addInInterface.h:155
@ actuatorRightRefSwitch
Definition addInInterface.h:164
@ actuatorEndSwitch1
Definition addInInterface.h:160
@ actuatorInterrupted
Definition addInInterface.h:152
@ actuatorLeftRefSwitch
Definition addInInterface.h:163
@ actSwitchesMask
Definition addInInterface.h:182
@ actuatorRefSwitch1
Definition addInInterface.h:165
@ actuatorEndSwitch
Definition addInInterface.h:157
@ actuatorRefSwitch
Definition addInInterface.h:162
@ actuatorAtTarget
Definition addInInterface.h:154
@ actRefSwitchMask
Definition addInInterface.h:178
@ retOk
Definition typeDefs.h:58
Definition addInInterface.h:391
Definition addInInterface.h:201
QVector< Param > paramsOut
Definition addInInterface.h:205
QVector< Param > paramsOpt
Definition addInInterface.h:204
QVector< Param > paramsMand
Definition addInInterface.h:203
Definition addInInterface.h:210