itom 2.2.1
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom and its software development toolkit (SDK). 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 In addition, as a special exception, the Institut fuer Technische 00015 Optik (ITO) gives you certain additional rights. 00016 These rights are described in the ITO LGPL Exception version 1.0, 00017 which can be found in the file LGPL_EXCEPTION.txt in this package. 00018 00019 itom is distributed in the hope that it will be useful, but 00020 WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00022 General Public Licence for more details. 00023 00024 You should have received a copy of the GNU Library General Public License 00025 along with itom. If not, see <http://www.gnu.org/licenses/>. 00026 *********************************************************************** */ 00027 00028 #ifndef ADDININTERFACE_H 00029 #define ADDININTERFACE_H 00030 00031 #include "commonGlobal.h" 00032 00033 #include "apiFunctionsInc.h" 00034 #include "apiFunctionsGraphInc.h" 00035 00036 #include "sharedStructuresQt.h" 00037 #include "sharedStructures.h" 00038 00039 #include <qlist.h> 00040 #include <qmap.h> 00041 #include <qpair.h> 00042 #include <qset.h> 00043 #include <qthread.h> 00044 #include <qsharedpointer.h> 00045 #include <qmutex.h> 00046 00047 #if QT_VERSION < 0x050000 00048 #include <qpluginloader.h> 00049 #include <qdockwidget.h> 00050 #else 00051 #include <QtCore/qpluginloader.h> 00052 #include <QtWidgets/qdockwidget.h> 00053 #endif 00054 00055 //plugins define VISUAL_LEAK_DETECTOR_CMAKE in their CMake configuration file 00056 #if defined _DEBUG && defined(_MSC_VER) && defined(VISUAL_LEAK_DETECTOR_CMAKE) 00057 #ifndef NOMINAX 00058 #define NOMINMAX //instead min, max is defined as macro in winDef.h, included by vld.h 00059 #include "vld.h" 00060 #undef NOMINMAX 00061 #else 00062 #include "vld.h" 00063 #endif 00064 #endif 00065 00066 #if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC) //only moc this file in itomCommonQtLib but not in other libraries or executables linking against this itomCommonQtLib 00067 00068 //write this macro right after Q_INTERFACE(...) in your interface class definition 00069 #define PLUGIN_ITOM_API \ 00070 protected: \ 00071 void importItomApi(void** apiPtr) \ 00072 {ito::ITOM_API_FUNCS = apiPtr;} \ 00073 void importItomApiGraph(void** apiPtr) \ 00074 { ito::ITOM_API_FUNCS_GRAPH = apiPtr;} \ 00075 public: \ 00076 //. 00077 00079 00083 #define NEW_PLUGININSTANCE(PluginClass) \ 00084 PluginClass* newInst = new PluginClass(); \ 00085 newInst->setBasePlugin(this); \ 00086 *addInInst = qobject_cast<ito::AddInBase*>(newInst); \ 00087 m_InstList.append(*addInInst); 00088 00090 00095 #define REMOVE_PLUGININSTANCE(PluginClass) \ 00096 if (*addInInst) \ 00097 { \ 00098 delete qobject_cast<PluginClass*>(*addInInst); \ 00099 m_InstList.removeOne(*addInInst); \ 00100 } 00101 00103 00107 #define REGISTER_FILTERS_AND_WIDGETS \ 00108 foreach(ito::AddInAlgo::FilterDef *f, newInst->m_filterList) \ 00109 { \ 00110 f->m_pBasePlugin = this; \ 00111 } \ 00112 foreach(ito::AddInAlgo::AlgoWidgetDef *w, newInst->m_algoWidgetList) \ 00113 { \ 00114 w->m_pBasePlugin = this; \ 00115 } 00116 00117 00118 namespace ito 00119 { 00120 //---------------------------------------------------------------------------------------------------------------------------------- 00122 00126 enum tPluginType { 00127 typeDataIO = 0x1, 00128 typeActuator = 0x2, 00129 typeAlgo = 0x4, 00130 typeGrabber = 0x80, 00131 typeADDA = 0x100, 00132 typeRawIO = 0x200 00133 }; 00134 00136 00145 enum tActuatorStatus { 00146 //moving flags 00147 actuatorUnknown = 0x0001, 00148 actuatorInterrupted = 0x0002, 00149 actuatorMoving = 0x0004, 00150 actuatorAtTarget = 0x0008, 00151 actuatorTimeout = 0x0010, 00152 //switches 00153 actuatorEndSwitch = 0x0100, 00154 actuatorLeftEndSwitch = 0x0200, 00155 actuatorRightEndSwitch = 0x0400, 00156 actuatorRefSwitch = 0x0800, 00157 actuatorLeftRefSwitch = 0x1000, 00158 actuatorRightRefSwitch = 0x2000, 00159 //status flags 00160 actuatorAvailable = 0x4000, 00161 actuatorEnabled = 0x8000, 00163 actMovingMask = actuatorUnknown | actuatorInterrupted | actuatorMoving | actuatorAtTarget | actuatorTimeout, 00164 actEndSwitchMask = actuatorEndSwitch | actuatorLeftEndSwitch | actuatorRightEndSwitch, 00165 actRefSwitchMask = actuatorRefSwitch | actuatorLeftRefSwitch | actuatorRightRefSwitch, 00166 actSwitchesMask = actEndSwitchMask | actRefSwitchMask, 00167 actStatusMask = actuatorAvailable | actuatorEnabled 00168 }; 00169 00170 enum tAutoLoadPolicy { 00171 autoLoadAlways = 0x1, 00172 autoLoadNever = 0x2, 00173 autoLoadKeywordDefined = 0x4 00174 }; 00175 00176 enum tAutoSavePolicy { 00177 autoSaveAlways = 0x1, 00178 autoSaveNever = 0x2 00179 }; 00180 00181 struct ExecFuncParams{ 00182 ExecFuncParams() : infoString("") {} 00183 QVector<Param> paramsMand; 00184 QVector<Param> paramsOpt; 00185 QVector<Param> paramsOut; 00186 QString infoString; 00187 }; 00188 00189 struct FilterParams { 00190 QVector<Param> paramsMand; 00191 QVector<Param> paramsOpt; 00192 QVector<Param> paramsOut; 00193 }; 00194 00195 class AddInBase; 00196 class DataObject; 00197 class AddInBasePrivate; 00198 00199 //---------------------------------------------------------------------------------------------------------------------------------- 00223 class ITOMCOMMONQT_EXPORT AddInInterfaceBase : public QObject 00224 { 00225 Q_OBJECT 00226 00227 private: 00229 virtual ito::RetVal closeThisInst(ito::AddInBase **addInInst) = 0; 00230 00231 protected: 00232 int m_type; 00233 int m_version; 00234 QString m_filename; 00235 int m_maxItomVer; 00236 int m_minItomVer; 00237 QString m_author; 00238 QString m_description; 00239 QString m_detaildescription; 00240 QString m_license; 00241 QString m_aboutThis; 00242 QList<ito::AddInBase *> m_InstList; 00243 QVector<ito::Param> m_initParamsMand; 00244 QVector<ito::Param> m_initParamsOpt; 00245 //bool m_enableAutoLoad; //* Varialbe to enable autoload for plugin. Standard value is false. Must be overwritten in AddInConstructor */ 00246 tAutoLoadPolicy m_autoLoadPolicy; 00247 tAutoSavePolicy m_autoSavePolicy; 00248 bool m_callInitInNewThread; 00249 QPluginLoader *m_loader; 00250 00251 virtual void importItomApi(void** apiPtr) = 0; //this methods are implemented in the plugin itsself. Therefore place ITOM_API right after Q_INTERFACE in the header file and replace Q_EXPORT_PLUGIN2 by Q_EXPORT_PLUGIN2_ITOM in the source file. 00252 virtual void importItomApiGraph(void** apiPtr) = 0; 00253 00254 public: 00255 void **m_apiFunctionsBasePtr; 00256 void **m_apiFunctionsGraphBasePtr; 00257 00258 virtual ~AddInInterfaceBase(); 00259 00261 AddInInterfaceBase() : 00262 m_type(0), m_version(CREATEVERSION(0,0,0)), m_filename(""), 00263 m_maxItomVer(MAXVERSION), m_minItomVer(MINVERSION), 00264 m_author(""), m_description(""), m_detaildescription(""), m_license("LGPL with ITO itom-exception"), m_aboutThis(""), 00265 /*m_enableAutoLoad(false),*/ m_autoLoadPolicy(ito::autoLoadNever), 00266 m_autoSavePolicy(ito::autoSaveNever), m_callInitInNewThread(true), m_apiFunctionsBasePtr(NULL), m_apiFunctionsGraphBasePtr(NULL), m_loader(NULL) 00267 { } 00268 00270 inline int getType(void) const { return m_type; } 00272 inline int getVersion(void) const { return m_version; } 00274 inline int getMinItomVer(void) const { return m_minItomVer; } 00276 inline int getMaxItomVer(void) const { return m_maxItomVer; } 00277 00279 inline bool getCallInitInNewThread(void) const { return m_callInitInNewThread; } 00280 00282 inline tAutoLoadPolicy getAutoLoadPolicy(void) const { return m_autoLoadPolicy; } 00283 00285 inline tAutoSavePolicy getAutoSavePolicy(void) const { return m_autoSavePolicy; } 00286 00288 const QString getAuthor(void) const { return m_author; } 00290 const QString getDescription(void) const { return m_description; } 00292 const QString getDetailDescription(void) const { return m_detaildescription; } 00294 const QString getLicenseInfo(void) const { return m_license; } 00296 const QString getAboutInfo(void) const { return m_aboutThis; } 00298 const QString getFilename(void) const { return m_filename; } 00299 00300 const ito::RetVal setFilename(const QString &name) { m_filename = name; return ito::retOk; } 00302 inline QList<ito::AddInBase *> getInstList(void) { return m_InstList; } 00303 inline const QList<ito::AddInBase *> getInstList(void) const { return m_InstList; } 00305 ito::RetVal closeInst(ito::AddInBase **addInInst); 00307 virtual QVector<ito::Param>* getInitParamsMand(void) { return &m_initParamsMand; } 00309 virtual QVector<ito::Param>* getInitParamsOpt(void) { return &m_initParamsOpt; } 00311 virtual ito::RetVal getAddInInst(ito::AddInBase **addInInst) = 0; 00313 void incRef(ito::AddInBase *addIn); 00315 void decRef(ito::AddInBase *addIn); 00317 int getRef(ito::AddInBase *addIn); 00319 int getInstCount() { return m_InstList.length(); } 00321 void setApiFunctions(void **apiFunctions); 00322 void setApiFunctionsGraph(void ** apiFunctionsGraph); 00323 inline void setLoader(QPluginLoader *loader) { m_loader = loader; } 00324 inline QPluginLoader * getLoader(void) { return m_loader; } 00325 00326 bool event(QEvent *e); 00327 00328 00329 }; 00330 00331 //---------------------------------------------------------------------------------------------------------------------------------- 00345 class ITOMCOMMONQT_EXPORT AddInBase : public QObject 00346 { 00347 Q_OBJECT 00348 00349 public: 00350 00351 struct AddInRef { 00352 AddInRef() : type(-1), ptr(0) {} 00353 AddInRef(void *p, int t) : type(t), ptr(p) {} 00354 int type; 00355 void *ptr; 00356 }; 00357 00359 const Param getParamRec(const QString name, bool *nameCheckOk = NULL) const; 00360 00362 AddInInterfaceBase* getBasePlugin(void) const; 00363 00365 ito::RetVal MoveToThread(void); 00366 00368 /* 00369 Use the method setParam in order to change any parameter. 00370 00371 \param paramNames [out]. The pointer contains a pointer to the map after the call of this function 00372 \return RetVal returns retOk. 00373 */ 00374 inline const ito::RetVal getParamList(QMap<QString, Param> **paramNames) { *paramNames = &m_params; return ito::retOk; } 00375 00377 /* 00378 \param [out] funcs is the pointer to a map, that points to the internal map of additional functions after the method-call. 00379 \return retOk 00380 \sa registerExecFunc 00381 */ 00382 inline const ito::RetVal getExecFuncList(QMap<QString, ExecFuncParams> **funcs) { *funcs = &m_execFuncList; return ito::retOk; } 00383 00385 int getID() const; 00386 00388 inline QString getIdentifier() const { return m_identifier; } 00389 00391 virtual int hasConfDialog(void); 00392 00394 virtual const ito::RetVal showConfDialog(void); 00395 00397 int createdByGUI() const; 00398 00400 void setCreatedByGUI(int value); 00401 00403 /* 00404 The reference counter is zero-based, hence, the value zero means that one reference is pointing to this instance 00405 */ 00406 inline int getRefCount(void) const 00407 { 00408 return m_refCount; 00409 } 00410 00412 /* 00413 \sa getDockWidget 00414 */ 00415 bool hasDockWidget(void) const; 00416 00418 /* 00419 \sa hasDockWidget 00420 */ 00421 QDockWidget* getDockWidget(void) const; 00422 00423 // doc in source 00424 virtual void dockWidgetDefaultStyle(bool &floating, bool &visible, Qt::DockWidgetArea &defaultArea) const; 00425 00427 /* 00428 Any time-consuming operation of the plugin should regularly set the alive-flag to true 00429 by calling setAlive. The state of this flag is returned by this method and afterwards 00430 reset to 0. This method is thread-safe. 00431 00432 \return current status of alive-flag (1 if "still alive", else 0) 00433 \sa setAlive 00434 */ 00435 int isAlive(void) 00436 { 00437 // QMutexLocker locker(&m_atomicMutex); 00438 int wasalive = m_alive; 00439 m_alive = 0; 00440 return wasalive; 00441 } 00442 00444 /* 00445 This method is thread-safe. 00446 00447 \sa isAlive 00448 */ 00449 void setAlive(void) 00450 { 00451 // QMutexLocker locker(&m_atomicMutex); 00452 m_alive = 1; 00453 } 00454 00456 bool isInitialized(void) const; 00457 00459 /* 00460 \param [in] initialized is the value to set 00461 */ 00462 void setInitialized(bool initialized); 00463 00465 /* 00466 This vector contains all plugin-instances, that have been passed to the init 00467 method of this plugin. The reference counter of these plugin is incremented at 00468 initialization of this plugin and decremented if this plugin will be destroyed. 00469 00470 \sa AddInRef, init 00471 */ 00472 QVector<ito::AddInBase::AddInRef *> * getArgAddIns(void) { return &m_hwDecList; } 00473 00474 static int getMaximumThreadCount(); 00475 static RetVal setMaximumThreadCount(int threadCount); 00476 00477 protected: 00478 // constructor (doc in source) 00479 AddInBase(); 00480 00481 // destructor (doc in source) 00482 virtual ~AddInBase(); 00483 00485 void setIdentifier(const QString &identifier); 00486 00487 //doc in source 00488 void createDockWidget(QString title, QDockWidget::DockWidgetFeatures features, Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas, QWidget *content = NULL); 00489 00490 // doc in source 00491 ito::RetVal registerExecFunc(const QString funcName, const QVector<ito::Param> ¶msMand, const QVector<ito::Param> ¶msOpt, const QVector<ito::Param> ¶msOut, const QString infoString); 00492 00494 void setBasePlugin(AddInInterfaceBase *base); 00495 00496 QMap<QString, Param> m_params; 00497 00498 QString m_identifier; 00499 00500 00501 private: 00502 Q_DISABLE_COPY(AddInBase) 00503 00504 00505 inline void incRefCount(void); 00506 00508 void decRefCount(void); 00509 00510 int m_refCount; 00511 QVector<ito::AddInBase::AddInRef *> m_hwDecList; 00512 QMap<QString, ExecFuncParams> m_execFuncList; 00513 QMutex m_refCountMutex; 00514 int m_alive; 00515 QMutex m_atomicMutex; 00516 AddInBasePrivate *aibp; 00517 00518 friend class AddInInterfaceBase; 00519 00520 static int m_instCounter; 00521 static int maxThreadCount; 00522 00523 signals: 00525 00533 void parametersChanged(QMap<QString, ito::Param> params); 00534 00535 public slots: 00537 virtual ito::RetVal init(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ItomSharedSemaphore *waitCond = NULL) = 0; 00539 virtual ito::RetVal close(ItomSharedSemaphore *waitCond) = 0; 00540 00542 virtual ito::RetVal getParam(QSharedPointer<ito::Param> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00544 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00545 00547 ito::RetVal setParamVector(const QVector<QSharedPointer<ito::ParamBase> > values, ItomSharedSemaphore *waitCond = NULL); 00548 00550 ito::RetVal getParamVector(const QVector<QSharedPointer<ito::Param> > values, ItomSharedSemaphore *waitCond = NULL); 00551 00553 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); 00554 00556 ito::RetVal moveBackToApplicationThread(ItomSharedSemaphore *waitCond = NULL); 00557 00558 private slots: 00560 00567 void sendParameterRequest(){ emit parametersChanged(m_params); }; 00568 00570 00578 virtual void dockWidgetVisibilityChanged(bool /*visible*/) {}; 00579 }; 00580 00581 //---------------------------------------------------------------------------------------------------------------------------------- 00608 class ITOMCOMMONQT_EXPORT AddInDataIO : public AddInBase 00609 { 00610 Q_OBJECT 00611 00612 private: 00613 Q_DISABLE_COPY (AddInDataIO) 00614 00615 protected: 00616 virtual ~AddInDataIO(); 00617 AddInDataIO(); 00618 00619 void runStatusChanged(bool deviceStarted); 00620 00621 //void timerEvent (QTimerEvent *event) = 0; //implement this event in your plugin, if you are a device, which is accessible by any liveImage!!! 00622 00623 QSet<QObject*> m_autoGrabbingListeners; 00624 int m_timerID; 00625 int m_timerIntervalMS; 00626 bool m_autoGrabbingEnabled; 00628 public: 00629 inline int getAutoGrabbing() { return m_autoGrabbingEnabled; } 00631 signals: 00632 00633 public slots: 00635 virtual ito::RetVal startDevice(ItomSharedSemaphore *waitCond); 00637 virtual ito::RetVal stopDevice(ItomSharedSemaphore *waitCond); 00639 virtual ito::RetVal acquire(const int trigger, ItomSharedSemaphore *waitCond = NULL); 00641 virtual ito::RetVal getVal(void* data, ItomSharedSemaphore *waitCond = NULL); 00643 virtual ito::RetVal getVal(QSharedPointer<char> data, QSharedPointer<int> length, ItomSharedSemaphore *waitCond = NULL); 00645 virtual ito::RetVal copyVal(void *dObj, ItomSharedSemaphore *waitCond); 00646 00648 virtual ito::RetVal setVal(const char *data, const int length, ItomSharedSemaphore *waitCond = NULL); 00649 00651 ito::RetVal enableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00652 00654 ito::RetVal disableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00655 00657 ito::RetVal setAutoGrabbingInterval(QSharedPointer<int> interval, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00658 00660 ito::RetVal startDeviceAndRegisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00661 00663 ito::RetVal stopDeviceAndUnregisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00664 }; 00665 00666 //---------------------------------------------------------------------------------------------------------------------------------- 00667 00668 00675 class ITOMCOMMONQT_EXPORT AddInActuator : public AddInBase 00676 { 00677 Q_OBJECT 00678 00679 private: 00680 Q_DISABLE_COPY (AddInActuator) 00681 00682 bool m_interruptFlag; 00683 QMutex m_interruptMutex; 00685 protected: 00686 virtual ~AddInActuator(); 00687 AddInActuator(); 00688 00689 QVector<int> m_currentStatus; 00690 QVector<double> m_currentPos; 00691 QVector<double> m_targetPos; 00693 00694 bool isMotorMoving() const 00695 { 00696 foreach(const int &i, m_currentStatus) 00697 { 00698 if (i & ito::actuatorMoving) 00699 { 00700 return true; 00701 } 00702 } 00703 return false; 00704 } 00705 00706 void sendStatusUpdate(const bool statusOnly = false); /* emits actuatorStatusChanged signal with the vector of currentStatus (and currentPos if statusOnly = false) to notify connected listeners about the current status (and position)*/ 00707 void sendTargetUpdate(); /* emits targetChanged with the vector of targetPositions to notify connected listeners about the change of the target position(s) */ 00708 00710 00714 virtual ito::RetVal waitForDone(const int timeoutMS = -1, const QVector<int> axis = QVector<int>() /*if empty -> all axis*/, const int flags = 0 /*for your use*/) = 0; 00715 00717 00727 inline void setStatus(int &status, const int newFlags, const int keepMask = 0) { status = (status & keepMask) | newFlags; } 00728 00730 00740 inline void setStatus(const QVector<int> &axis, const int newFlags, const int keepMask = 0) 00741 { 00742 foreach(const int &i, axis) 00743 { 00744 setStatus(m_currentStatus[i], newFlags, keepMask); 00745 } 00746 } 00747 00749 00758 inline void replaceStatus(int &status, const int existingFlag, const int replaceFlag) { if (status & existingFlag) { status = (status ^ existingFlag) | replaceFlag; } } 00759 00761 00771 inline void replaceStatus(const QVector<int> &axis, const int existingFlag, const int replaceFlag) 00772 { 00773 foreach(const int &i, axis) 00774 { 00775 replaceStatus(m_currentStatus[i], existingFlag, replaceFlag); 00776 } 00777 } 00778 00780 00786 bool isInterrupted() 00787 { 00788 QMutexLocker locker(&m_interruptMutex); 00789 bool res = m_interruptFlag; 00790 m_interruptFlag = false; 00791 return res; 00792 } 00793 00794 public: 00796 00803 void setInterrupt() 00804 { 00805 QMutexLocker locker(&m_interruptMutex); 00806 m_interruptFlag = true; 00807 } 00808 00809 00810 00811 signals: 00813 00822 void actuatorStatusChanged(QVector<int> status, QVector<double> actPosition); 00823 00825 00833 void targetChanged(QVector<double> targetPositions); 00834 00835 public slots: 00837 virtual ito::RetVal calib(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00839 virtual ito::RetVal calib(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00841 virtual ito::RetVal setOrigin(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00843 virtual ito::RetVal setOrigin(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00845 virtual ito::RetVal getStatus(QSharedPointer<QVector<int> > status, ItomSharedSemaphore *waitCond) = 0; 00847 virtual ito::RetVal getPos(const int axis, QSharedPointer<double> pos, ItomSharedSemaphore *waitCond) = 0; 00849 virtual ito::RetVal getPos(const QVector<int> axis, QSharedPointer<QVector<double> > pos, ItomSharedSemaphore *waitCond) = 0; 00851 virtual ito::RetVal setPosAbs(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00853 virtual ito::RetVal setPosAbs(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00855 virtual ito::RetVal setPosRel(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00857 virtual ito::RetVal setPosRel(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00858 00860 virtual ito::RetVal requestStatusAndPosition(bool sendCurrentPos, bool sendTargetPos); //added 2014-03-04 00861 }; 00862 00863 //---------------------------------------------------------------------------------------------------------------------------------- 00872 class ITOMCOMMONQT_EXPORT AddInAlgo : public AddInBase 00873 { 00874 Q_OBJECT 00875 00876 Q_ENUMS(tAlgoCategory) 00877 Q_ENUMS(tAlgoInterface) 00878 00879 private: 00880 Q_DISABLE_COPY(AddInAlgo) 00881 00882 public: 00883 typedef ito::RetVal (* t_filter)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, QVector<ito::ParamBase> *paramsOut); 00884 typedef QWidget* (* t_algoWidget)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ito::RetVal &retValue); 00885 typedef ito::RetVal (* t_filterParam)(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut); 00886 00888 enum tAlgoCategory 00889 { 00890 catNone = 0x0000, 00891 catDiskIO = 0x0001, 00892 catAnalyseDataObject = 0x0002, 00893 catPlotDataObject = 0x0004 00894 }; 00895 00897 enum tAlgoInterface 00898 { 00899 iNotSpecified = 0x0000, 00900 iReadDataObject = 0x0001, 00901 iWriteDataObject = 0x0002, 00902 iReadPointCloud = 0x0004, 00903 iWritePointCloud = 0x0008, 00904 iReadPolygonMesh = 0x0010, 00905 iWritePolygonMesh = 0x0020, 00906 iPlotSingleObject = 0x0040 00907 }; 00908 00910 class FilterDef 00911 { 00912 public: 00914 FilterDef() : 00915 m_filterFunc(NULL), 00916 m_paramFunc(NULL), 00917 m_pBasePlugin(NULL), 00918 m_category(ito::AddInAlgo::catNone), 00919 m_interface(ito::AddInAlgo::iNotSpecified) 00920 {} 00921 00923 FilterDef(AddInAlgo::t_filter filterFunc, AddInAlgo::t_filterParam filterParamFunc, QString description = QString(), ito::AddInAlgo::tAlgoCategory category = ito::AddInAlgo::catNone, ito::AddInAlgo::tAlgoInterface interf = ito::AddInAlgo::iNotSpecified, QString interfaceMeta = QString()) : 00924 m_filterFunc(filterFunc), 00925 m_paramFunc(filterParamFunc), 00926 m_pBasePlugin(NULL), 00927 m_description(description), 00928 m_category(category), 00929 m_interface(interf), 00930 m_interfaceMeta(interfaceMeta) 00931 {} 00932 00933 virtual ~FilterDef() {} 00934 00935 t_filter m_filterFunc; 00936 t_filterParam m_paramFunc; 00937 ito::AddInInterfaceBase *m_pBasePlugin; 00938 QString m_name; 00939 QString m_description; 00940 ito::AddInAlgo::tAlgoCategory m_category; 00941 ito::AddInAlgo::tAlgoInterface m_interface; 00942 QString m_interfaceMeta; 00943 private: 00944 FilterDef (const FilterDef & /*p*/); //disable copy constructor 00945 }; 00946 00948 class AlgoWidgetDef 00949 { 00950 public: 00952 AlgoWidgetDef() : 00953 m_widgetFunc(NULL), 00954 m_paramFunc(NULL), 00955 m_pBasePlugin(NULL), 00956 m_category(ito::AddInAlgo::catNone), 00957 m_interface(ito::AddInAlgo::iNotSpecified) 00958 {} 00959 00961 AlgoWidgetDef(AddInAlgo::t_algoWidget algoWidgetFunc, AddInAlgo::t_filterParam algoWidgetParamFunc, QString description = QString(), ito::AddInAlgo::tAlgoCategory category = ito::AddInAlgo::catNone, ito::AddInAlgo::tAlgoInterface interf = ito::AddInAlgo::iNotSpecified, QString interfaceMeta = QString()) : 00962 m_widgetFunc(algoWidgetFunc), 00963 m_paramFunc(algoWidgetParamFunc), 00964 m_pBasePlugin(NULL), 00965 m_description(description), 00966 m_category(category), 00967 m_interface(interf), 00968 m_interfaceMeta(interfaceMeta) 00969 {} 00970 00971 virtual ~AlgoWidgetDef() {} 00972 00973 t_algoWidget m_widgetFunc; 00974 t_filterParam m_paramFunc; 00975 ito::AddInInterfaceBase *m_pBasePlugin; 00976 QString m_name; 00977 QString m_description; 00978 ito::AddInAlgo::tAlgoCategory m_category; 00979 ito::AddInAlgo::tAlgoInterface m_interface; 00980 QString m_interfaceMeta; 00981 00982 private: 00983 AlgoWidgetDef (const AlgoWidgetDef & /*p*/); //disable copy constructor 00984 }; 00985 00986 ito::RetVal getFilterList(QHash<QString, FilterDef *> &fList) const; 00987 ito::RetVal getAlgoWidgetList(QHash<QString, AlgoWidgetDef *> &awList) const; 00988 ito::RetVal rejectFilter(const QString &name); 00989 ito::RetVal rejectAlgoWidget(const QString &name); 00990 00991 protected: 00992 virtual ~AddInAlgo(); 00993 AddInAlgo(); 00994 QHash<QString, FilterDef *> m_filterList; 00995 QHash<QString, AlgoWidgetDef *> m_algoWidgetList; 00996 00997 static ito::RetVal prepareParamVectors(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut) 00998 { 00999 if (!paramsMand) 01000 { 01001 return RetVal(ito::retError, 0, tr("uninitialized vector for mandatory parameters!").toLatin1().data()); 01002 } 01003 if (!paramsOpt) 01004 { 01005 return RetVal(ito::retError, 0, tr("uninitialized vector for optional parameters!").toLatin1().data()); 01006 } 01007 if (!paramsOut) 01008 { 01009 return RetVal(ito::retError, 0, tr("uninitialized vector for output parameters!").toLatin1().data()); 01010 } 01011 paramsMand->clear(); 01012 paramsOpt->clear(); 01013 paramsOut->clear(); 01014 return ito::retOk; 01015 } 01016 01017 public slots: 01018 virtual ito::RetVal getParam(QSharedPointer<ito::Param> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 01019 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 01020 }; 01021 01022 //---------------------------------------------------------------------------------------------------------------------------------- 01023 } // namespace ito 01024 01025 #endif //#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC) 01026 01027 //########################################################################################################### 01028 // Interface version: 01029 //########################################################################################################### 01030 // 01031 // 01032 // Please change the interface version, if you made any changes to this interface, files located in the common folder or to the dataObject. 01033 // 01034 // To add a new version, do the following steps 01035 // 01036 // 1. append the string behind the variable ito_AddInInterface_CurrentVersion (e.g. ito.AddIn.InterfaceBase/1.1) to the array ito_AddInInterface_OldVersions 01037 // 2. change the version number in the string ito_AddInInterface_CurrentVersion 01038 // 3. if the AddInInterface version number is incremented, the ito.AbstractItomDesignerPlugin number in AbstractItomDesignerPlugin.h must be incremented as well. 01039 // 01040 // 01041 // This helps, that deprecated or "future" plugins, which fit not to the current implementation of the interface will not be loaded 01042 // but a sophisticated error message is shown. 01043 01044 static const char* ito_AddInInterface_OldVersions[] = { 01045 "ito.AddIn.InterfaceBase/1.0", //version from start of development until 2012-10-11 01046 "ito.AddIn.InterfaceBase/1.1", //version until 2012-10-15 (outdated due to changes in dataObject) 01047 "ito.AddIn.InterfaceBase/1.1.1", //version until 2012-10-21 (outdated due to small changes in addInInterface) 01048 "ito.AddIn.InterfaceBase/1.1.2", //version until 2012-10-30 (outdated due to small changes in addInInterface) 01049 "ito.AddIn.InterfaceBase/1.1.3", //version until 2012-11-09 (outdated due to changes in the checkData()-function in addInGrabber) 01050 "ito.AddIn.InterfaceBase/1.1.4", //version until 2012-11-12 (outdated due to changes in the DataObject) 01051 "ito.AddIn.InterfaceBase/1.1.5", //version until 2012-11-18 (outdated: changes in the API structure) 01052 "ito.AddIn.InterfaceBase/1.1.6", //version until 2012-12-20 (outdated: added paramBase metatype) 01053 "ito.AddIn.InterfaceBase/1.1.7", //version until 2013-01-17 (outdated: last version for itom version 1.0.5) 01054 "ito.AddIn.InterfaceBase/1.1.8", //version until 2013-01-23 (outdated: changes in auto-grabbing of cameras, first interface for itom version 1.0.6) 01055 "ito.AddIn.InterfaceBase/1.1.9", //version until 2013-03-04 (outdated: changes in dataObjectHelper) 01056 "ito.AddIn.InterfaceBase/1.1.10",//version until 2013-03-12 (outdated: Added license and about string to the plugin) 01057 "ito.AddIn.InterfaceBase/1.1.11",//version until 2013-03-22 (outdated: bugfix in ito::ParamBase) 01058 "ito.AddIn.InterfaceBase/1.1.12",//version until 2013-03-25 (outdated: changes in api) 01059 "ito.AddIn.InterfaceBase/1.1.13",//version until 2013-04-08 (outdated: removed transpose flag in dataObject) 01060 "ito.AddIn.InterfaceBase/1.1.14",//version until 2013-04-17 (outdated: uniqueID and identifier inserted/changed) 01061 "ito.AddIn.InterfaceBase/1.1.15",//version until 2013-04-23 (outdated: made some tag-space related methods non-inline (due to linker errors in MSVC)) 01062 "ito.AddIn.InterfaceBase/1.1.16",//version until 2013-06-07 (outdated: added qpluginloader to the interface for cleaner unloading of plugins) 01063 "ito.AddIn.InterfaceBase/1.1.17",//version until 2013-06-11 (outdated: apis extended, changes in param-class) 01064 "ito.AddIn.InterfaceBase/1.1.18",//version until 2013-06-18 (outdated: iterator and constIterator introduced for dataObject) 01065 "ito.AddIn.InterfaceBase/1.1.19",//version until 2013-08-15 (outdated: operators +, +=, -, -= introduced for scalar operands) 01066 "ito.AddIn.InterfaceBase/1.1.20",//version until 2013-10-10 (outdated: RGBA-type introduced into dataObjectTypes) 01067 "ito.AddIn.InterfaceBase/1.1.21",//version until 2013-10-15 (outdated: getSize(..) and getTotalSize(..) return int now and -1 if error. Consistency to documented behaviour) 01068 "ito.AddIn.InterfaceBase/1.1.22",//version until 2013-10-27 (outdated: class Rgba32Base in typedefs.h and inherited class Rgba32 in color.h introduced, improved data() method in dataObj) 01069 "ito.AddIn.InterfaceBase/1.1.23",//version until 2013-12-17 (outdated: changed dataObject internal size parameters (back) from size_t to int - hopfully last time) 01070 "ito.AddIn.InterfaceBase/1.1.24",//version until 2014-02-09 (outdated: restructuring to itomCommonLib and itomCommonQtLib for a better binary compatibility) 01071 "ito.AddIn.InterfaceBase/1.2.0", //outdated on 2014-03-14 due to change in AddInDataIO::setVal(const char *data, const int length, ItomSharedSemaphore *waitCond = NULL); (const void *data changed to const char *data) (Qt5 bugfix) 01072 "ito.AddIn.InterfaceBase/1.2.1", //outdated on 2014-10-06 due to changes in APIs, retVal.h and itomWidgets-project. The next version 1.3.0 is the version for the setup 1.3.0. 01073 "ito.AddIn.InterfaceBase/1.3.0", //outdated on 2014-10-27 due to insertion of ito::AutoInterval object and addition of further ito::ParamMeta classes. 01074 "ito.AddIn.InterfaceBase/1.3.1", //outdated on 2015-03-01 due to rework on data object 01075 "ito.AddIn.InterfaceBase/1.4.0", //outdated on 2015-07-03 due to removal of lock mechanism in data object, add of embedded line plots, qt5 incompatiblity changes and some refinements in addInInterface 01076 "ito.AddIn.InterfaceBase/2.0.0", //outdated on 2015-12-04 due to improvements in plot/figure interfaces, removal of deprecated classes helperActuator and helperGrabber and further removal of deprecated items 01077 "ito.AddIn.InterfaceBase/2.1.0", //outdated on 2016-02-01 due to improvements in PluginThreadCtrl, ActuatorThreadCtrl and DataIoThreadCtrl (as replacement for removed classes helperActuator and helperGrabber), new method ito::DataObject::getStep and some smaller rearrangements 01078 "ito.AddIn.InterfaceBase/2.2.0", //outdated on 2016-02-19 due to crash fixes if the main mindow is deleted and implicitely closes dock widgets of plugins, that are currently blocked by any other operation. 01079 "ito.AddIn.InterfaceBase/2.3.0", //outdated on 2016-06-14 due to changes in signal definitions in plots, introduction of complex and complexArray types in ParamBase and further smaller changes. 01080 "ito.AddIn.InterfaceBase/2.4.0", //outdated on 2016-07-12 due to new library itomCommonPlotLib. 01081 NULL 01082 }; 01083 01084 //these defines exist since itom 1.3.1 01085 #define CREATE_ADDININTERFACE_VERSION_STR(major,minor,patch) "ito.AddIn.InterfaceBase/"#major"."#minor"."#patch 01086 #define CREATE_ADDININTERFACE_VERSION(major,minor,patch) ((major<<16)|(minor<<8)|(patch)) 01087 01088 #define ITOM_ADDININTERFACE_MAJOR 2 01089 #define ITOM_ADDININTERFACE_MINOR 5 01090 #define ITOM_ADDININTERFACE_PATCH 0 01091 #define ITOM_ADDININTERFACE_VERSION CREATE_ADDININTERFACE_VERSION(ITOM_ADDININTERFACE_MAJOR,ITOM_ADDININTERFACE_MINOR,ITOM_ADDININTERFACE_PATCH) 01092 static const char* ito_AddInInterface_CurrentVersion = CREATE_ADDININTERFACE_VERSION_STR(2,5,0); //results in "ito.AddIn.InterfaceBase/x.x.x"; (the numbers 1,3,1 can not be replaced by the macros above. Does not work properly) 01093 01094 01095 01097 Q_DECLARE_INTERFACE(ito::AddInInterfaceBase, ito_AddInInterface_CurrentVersion /*"ito.AddIn.InterfaceBase/1.1"*/) 01098 01099 #endif