itom 1.1.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität 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 für 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 "apiFunctionsInc.h" 00032 #include "apiFunctionsGraphInc.h" 00033 00034 #include "sharedStructuresQt.h" 00035 #include "sharedStructures.h" 00036 00037 #include <qlist.h> 00038 #include <qmap.h> 00039 #include <qpair.h> 00040 #include <qset.h> 00041 #include <qthread.h> 00042 #include <qsharedpointer.h> 00043 #include <qwidget.h> 00044 #include <qdockwidget.h> 00045 #include <qmutex.h> 00046 #include <qevent.h> 00047 #include <qpluginloader.h> 00048 00049 namespace ito 00050 { 00051 00057 enum tPluginType { 00058 typeDataIO = 0x1, 00059 typeActuator = 0x2, 00060 typeAlgo = 0x4, 00061 typeGrabber = 0x80, 00062 typeADDA = 0x100, 00063 typeRawIO = 0x200 00064 }; 00065 00066 enum tActuatorStatus { 00067 //moving flags 00068 actuatorUnknown = 0x0001, 00069 actuatorInterrupted = 0x0002, 00070 actuatorMoving = 0x0004, 00071 actuatorAtTarget = 0x0008, 00072 actuatorTimeout = 0x0010, 00073 //switches 00074 actuatorEndSwitch = 0x0100, 00075 actuatorLeftEndSwitch = 0x0200, 00076 actuatorRightEndSwitch = 0x0400, 00077 actuatorRefSwitch = 0x0800, 00078 actuatorLeftRefSwitch = 0x1000, 00079 actuatorRightRefSwitch = 0x2000, 00080 //status flags 00081 actuatorAvailable = 0x4000, 00082 actuatorEnabled = 0x8000, 00083 00084 actMovingMask = actuatorUnknown | actuatorInterrupted | actuatorMoving | actuatorAtTarget | actuatorTimeout, 00085 actEndSwitchMask = actuatorEndSwitch | actuatorLeftEndSwitch | actuatorRightEndSwitch, 00086 actRefSwitchMask = actuatorRefSwitch | actuatorLeftRefSwitch | actuatorRightRefSwitch, 00087 actSwitchesMask = actEndSwitchMask | actRefSwitchMask, 00088 actStatusMask = actuatorAvailable | actuatorEnabled 00089 00090 }; 00091 00092 enum tAutoLoadPolicy { 00093 autoLoadAlways = 0x1, 00094 autoLoadNever = 0x2, 00095 autoLoadKeywordDefined = 0x4 00096 }; 00097 00098 enum tAutoSavePolicy { 00099 autoSaveAlways = 0x1, 00100 autoSaveNever = 0x2 00101 }; 00102 00103 struct ExecFuncParams{ 00104 ExecFuncParams() : infoString("") {} 00105 QVector<Param> paramsMand; 00106 QVector<Param> paramsOpt; 00107 QVector<Param> paramsOut; 00108 QString infoString; 00109 }; 00110 00111 struct FilterParams { 00112 QVector<Param> paramsMand; 00113 QVector<Param> paramsOpt; 00114 QVector<Param> paramsOut; 00115 }; 00116 00117 class AddInBase; 00118 class ActuatorAxis; 00119 class DataObject; 00120 00121 //---------------------------------------------------------------------------------------------------------------------------------- 00145 class AddInInterfaceBase : public QObject 00146 { 00147 Q_OBJECT 00148 00149 private: 00151 virtual ito::RetVal closeThisInst(ito::AddInBase **addInInst) = 0; 00152 00153 protected: 00154 int m_type; 00155 int m_version; 00156 QString m_filename; 00157 int m_maxItomVer; 00158 int m_minItomVer; 00159 QString m_author; 00160 QString m_description; 00161 QString m_detaildescription; 00162 QString m_license; 00163 QString m_aboutThis; 00164 QList<ito::AddInBase *> m_InstList; 00165 QVector<ito::Param> m_initParamsMand; 00166 QVector<ito::Param> m_initParamsOpt; 00167 //bool m_enableAutoLoad; //* Varialbe to enable autoload for plugin. Standard value is false. Must be overwritten in AddInConstructor */ 00168 tAutoLoadPolicy m_autoLoadPolicy; 00169 tAutoSavePolicy m_autoSavePolicy; 00170 bool m_callInitInNewThread; 00171 QPluginLoader *m_loader; 00172 00173 public: 00174 void **m_apiFunctionsBasePtr; 00175 void **m_apiFunctionsGraphBasePtr; 00176 00177 virtual ~AddInInterfaceBase(); 00178 00180 AddInInterfaceBase() : 00181 m_type(0), m_version(CREATEVERSION(0,0,0)), m_filename(""), 00182 m_maxItomVer(MAXVERSION), m_minItomVer(MINVERSION), 00183 m_author(""), m_description(""), m_detaildescription(""), m_license("LGPL with ITO itom-exception"), m_aboutThis(""), 00184 /*m_enableAutoLoad(false),*/ m_autoLoadPolicy(ito::autoLoadNever), 00185 m_autoSavePolicy(ito::autoSaveNever), m_callInitInNewThread(true), m_apiFunctionsBasePtr(NULL), m_apiFunctionsGraphBasePtr(NULL), m_loader(NULL) 00186 { } 00187 00189 inline int getType(void) const { return m_type; } 00191 inline int getVersion(void) const { return m_version; } 00193 inline int getMinItomVer(void) const { return m_minItomVer; } 00195 inline int getMaxItomVer(void) const { return m_maxItomVer; } 00196 00198 inline bool getCallInitInNewThread(void) const { return m_callInitInNewThread; } 00199 00201 inline tAutoLoadPolicy getAutoLoadPolicy(void) const { return m_autoLoadPolicy; } 00202 00204 inline tAutoSavePolicy getAutoSavePolicy(void) const { return m_autoSavePolicy; } 00205 00207 const QString getAuthor(void) const { return m_author; } 00209 const QString getDescription(void) const { return m_description; } 00211 const QString getDetailDescription(void) const { return m_detaildescription; } 00213 const QString getLicenseInfo(void) const { return m_license; } 00215 const QString getAboutInfo(void) const { return m_aboutThis; } 00217 const QString getFilename(void) const { return m_filename; } 00218 00219 const ito::RetVal setFilename(const QString &name) { m_filename = name; return ito::retOk; } 00221 inline QList<ito::AddInBase *> getInstList(void) { return m_InstList; } 00222 inline const QList<ito::AddInBase *> getInstList(void) const { return m_InstList; } 00224 ito::RetVal closeInst(ito::AddInBase **addInInst); 00226 virtual QVector<ito::Param>* getInitParamsMand(void) { return &m_initParamsMand; } 00228 virtual QVector<ito::Param>* getInitParamsOpt(void) { return &m_initParamsOpt; } 00230 virtual ito::RetVal getAddInInst(ito::AddInBase **addInInst) = 0; 00232 void incRef(ito::AddInBase *addIn); 00234 void decRef(ito::AddInBase *addIn); 00236 int getRef(ito::AddInBase *addIn); 00238 int getInstCount() { return m_InstList.length(); } 00240 void setApiFunctions(void **apiFunctions); 00241 void setApiFunctionsGraph(void ** apiFunctionsGraph); 00242 inline void setLoader(QPluginLoader *loader) { m_loader = loader; } 00243 inline QPluginLoader * getLoader(void) { return m_loader; } 00244 00245 bool event(QEvent *e); 00246 00247 //signals: 00248 00249 //public slots: 00250 }; 00251 00252 //---------------------------------------------------------------------------------------------------------------------------------- 00266 class AddInBase : public QObject 00267 { 00268 Q_OBJECT 00269 00270 public: 00271 00272 struct AddInRef { 00273 AddInRef() : type(-1), ptr(0) {} 00274 AddInRef(void *p, int t) : type(t), ptr(p) {} 00275 int type; 00276 void *ptr; 00277 }; 00278 00280 00297 const Param getParamRec(const QString name, bool *nameCheckOk = NULL) const 00298 { 00299 QRegExp rx("^([a-zA-Z]+\\w*)(\\[(\\d+)\\]){0,1}(:(.*)){0,1}$"); 00300 if (rx.indexIn(name) == -1) 00301 { 00302 if (nameCheckOk) *nameCheckOk = false; 00303 return Param(); 00304 } 00305 else 00306 { 00307 QStringList pname = rx.capturedTexts(); 00308 if (pname.length() > 1) 00309 { 00310 if (nameCheckOk) *nameCheckOk = true; 00311 ito::Param tempParam = m_params.value(pname[1]); 00312 if (pname[2].length()) 00313 tempParam.addNameSuffix(pname[2].toAscii().data()); 00314 if (pname[4].length()) 00315 tempParam.addNameSuffix(pname[4].toAscii().data()); 00316 return tempParam; //returns default constructor if value not available in m_params. Default constructor has member isValid() => false 00317 } 00318 } 00319 return Param(); 00320 } 00321 00323 inline AddInInterfaceBase* getBasePlugin(void) const { return m_pBasePlugin; } 00324 00326 inline ito::RetVal MoveToThread(void) 00327 { 00328 m_pThread = new QThread(); 00329 moveToThread(m_pThread); 00330 m_pThread->start(); 00331 return retOk; 00332 } 00333 00335 /* 00336 Use the method setParam in order to change any parameter. 00337 00338 \param paramNames [out]. The pointer contains a pointer to the map after the call of this function 00339 \return RetVal returns retOk. 00340 */ 00341 inline const ito::RetVal getParamList(QMap<QString, Param> **paramNames) { *paramNames = &m_params; return ito::retOk; } 00342 00344 /* 00345 \param [out] funcs is the pointer to a map, that points to the internal map of additional functions after the method-call. 00346 \return retOk 00347 \sa registerExecFunc 00348 */ 00349 inline const ito::RetVal getExecFuncList(QMap<QString, ExecFuncParams> **funcs) { *funcs = &m_execFuncList; return ito::retOk; } 00350 00352 inline int getID() const { return m_uniqueID; } 00353 00355 inline QString getIdentifier() const { return m_identifier; } 00356 00358 virtual int hasConfDialog(void); 00359 00361 virtual const ito::RetVal showConfDialog(void); 00362 00364 inline int createdByGUI() const { return m_createdByGUI; } 00365 00367 inline void setCreatedByGUI(int value) { m_createdByGUI = value; } 00368 00370 /* 00371 The reference counter is zero-based, hence, the value zero means that one reference is pointing to this instance 00372 */ 00373 inline int getRefCount(void) 00374 { 00375 return m_refCount; 00376 } 00377 00379 /* 00380 \sa getDockWidget 00381 */ 00382 inline bool hasDockWidget(void) const { return m_dockWidget ? true : false; } 00383 00385 /* 00386 \sa hasDockWidget 00387 */ 00388 inline QDockWidget* getDockWidget(void) const { return m_dockWidget; } 00389 00390 // doc in source 00391 virtual void dockWidgetDefaultStyle(bool &floating, bool &visible, Qt::DockWidgetArea &defaultArea) const; 00392 00394 /* 00395 Any time-consuming operation of the plugin should regularly set the alive-flag to true 00396 by calling setAlive. The state of this flag is returned by this method and afterwards 00397 reset to 0. This method is thread-safe. 00398 00399 \return current status of alive-flag (1 if "still alive", else 0) 00400 \sa setAlive 00401 */ 00402 int isAlive(void) 00403 { 00404 // QMutexLocker locker(&m_atomicMutex); 00405 int wasalive = m_alive; 00406 m_alive = 0; 00407 return wasalive; 00408 } 00409 00411 /* 00412 This method is thread-safe. 00413 00414 \sa isAlive 00415 */ 00416 void setAlive(void) 00417 { 00418 // QMutexLocker locker(&m_atomicMutex); 00419 m_alive = 1; 00420 } 00421 00423 bool isInitialized(void) 00424 { 00425 // QMutexLocker locker(&m_atomicMutex); 00426 return m_initialized; 00427 } 00428 00430 /* 00431 \param [in] initialized is the value to set 00432 */ 00433 void setInitialized(bool initialized) 00434 { 00435 // QMutexLocker locker(&m_atomicMutex); 00436 m_initialized = initialized; 00437 } 00438 00440 /* 00441 This vector contains all plugin-instances, that have been passed to the init 00442 method of this plugin. The reference counter of these plugin is incremented at 00443 initialization of this plugin and decremented if this plugin will be destroyed. 00444 00445 \sa AddInRef, init 00446 */ 00447 QVector<ito::AddInBase::AddInRef *> * getArgAddIns(void) { return &m_hwDecList; } 00448 00449 protected: 00450 // constructor (doc in source) 00451 AddInBase(); 00452 00453 // destructor (doc in source) 00454 virtual ~AddInBase(); 00455 00456 //doc in source 00457 void createDockWidget(QString title, QDockWidget::DockWidgetFeatures features, Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas, QWidget *content = NULL); 00458 00459 // doc in source 00460 ito::RetVal registerExecFunc(const QString funcName, const QVector<ito::Param> ¶msMand, const QVector<ito::Param> ¶msOpt, const QVector<ito::Param> ¶msOut, const QString infoString); 00461 00463 inline void setBasePlugin(AddInInterfaceBase *base) { m_pBasePlugin = base; } 00464 00465 QThread *m_pThread; 00466 AddInInterfaceBase *m_pBasePlugin; 00467 QMap<QString, Param> m_params; 00468 00469 QString m_identifier; 00470 int m_refCount; 00471 int m_createdByGUI; 00472 QVector<ito::AddInBase::AddInRef *> m_hwDecList; 00473 QMap<QString, ExecFuncParams> m_execFuncList; 00474 00475 private: 00476 Q_DISABLE_COPY (AddInBase) 00477 00478 00479 inline void incRefCount(void) 00480 { 00481 m_refCountMutex.lock(); 00482 m_refCount++; 00483 m_refCountMutex.unlock(); 00484 } 00485 00487 inline void decRefCount(void) 00488 { 00489 m_refCountMutex.lock(); 00490 m_refCount--; 00491 m_refCountMutex.unlock(); 00492 } 00493 00494 int m_uniqueID; 00495 00496 QMutex m_refCountMutex; 00497 QDockWidget *m_dockWidget; 00498 int m_alive; 00499 QMutex m_atomicMutex; 00500 bool m_initialized; 00501 00502 friend class AddInInterfaceBase; 00503 00504 static int m_instCounter; 00505 00506 signals: 00508 00516 void parametersChanged(QMap<QString, ito::Param> params); 00517 00518 public slots: 00519 00521 virtual ito::RetVal init(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ItomSharedSemaphore *waitCond = NULL) = 0; 00523 virtual ito::RetVal close(ItomSharedSemaphore *waitCond) = 0; 00524 00526 virtual ito::RetVal getParam(QSharedPointer<ito::Param> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00528 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00529 00530 // doc in source-file 00531 ito::RetVal setParamVector(const QVector<QSharedPointer<ito::ParamBase> > values, ItomSharedSemaphore *waitCond = NULL); 00532 00533 // doc in source-file 00534 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); 00535 00536 00537 private slots: 00539 00546 void sendParameterRequest(){ emit parametersChanged(m_params); }; 00547 00549 00557 virtual void dockWidgetVisibilityChanged(bool /*visible*/) {}; 00558 00560 00565 void dockWidgetDestroyed() { m_dockWidget = NULL; } 00566 }; 00567 00568 //---------------------------------------------------------------------------------------------------------------------------------- 00595 class AddInDataIO : public AddInBase 00596 { 00597 Q_OBJECT 00598 00599 private: 00600 Q_DISABLE_COPY (AddInDataIO) 00601 00602 protected: 00603 virtual ~AddInDataIO() = 0; 00604 AddInDataIO(); 00605 00606 void runStatusChanged(bool deviceStarted); 00607 00608 //void timerEvent (QTimerEvent *event) = 0; //implement this event in your plugin, if you are a device, which is accessible by any liveImage!!! 00609 00610 QSet<QObject*> m_autoGrabbingListeners; 00611 int m_timerID; 00612 int m_timerIntervalMS; 00613 bool m_autoGrabbingEnabled; 00615 public: 00616 inline int getAutoGrabbing() { return m_autoGrabbingEnabled; } 00618 signals: 00619 00620 public slots: 00622 virtual ito::RetVal startDevice(ItomSharedSemaphore *waitCond); 00624 virtual ito::RetVal stopDevice(ItomSharedSemaphore *waitCond); 00626 virtual ito::RetVal acquire(const int trigger, ItomSharedSemaphore *waitCond = NULL); 00628 virtual ito::RetVal getVal(void* data, ItomSharedSemaphore *waitCond = NULL); 00630 virtual ito::RetVal getVal(QSharedPointer<char> data, QSharedPointer<int> length, ItomSharedSemaphore *waitCond = NULL); 00632 virtual ito::RetVal copyVal(void *dObj, ItomSharedSemaphore *waitCond); 00633 00635 virtual ito::RetVal setVal(const void *data, const int length, ItomSharedSemaphore *waitCond = NULL); 00636 00638 ito::RetVal enableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00639 00641 ito::RetVal disableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00642 00644 ito::RetVal startDeviceAndRegisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00645 00647 ito::RetVal stopDeviceAndUnregisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00648 }; 00649 00650 //---------------------------------------------------------------------------------------------------------------------------------- 00651 00652 00659 class AddInActuator : public AddInBase 00660 { 00661 Q_OBJECT 00662 00663 private: 00664 Q_DISABLE_COPY (AddInActuator) 00665 00666 int m_nrOfStatusChangedConnections; 00667 int m_nrOfTargetChangedConnections; 00668 bool m_interruptFlag; 00669 QMutex m_interruptMutex; 00671 protected: 00672 virtual ~AddInActuator() = 0; 00673 AddInActuator(); 00674 00675 virtual void connectNotify (const char * signal); 00676 virtual void disconnectNotify (const char * signal); 00677 int nrOfStatusChangedConnections() const { return m_nrOfStatusChangedConnections; } 00678 int nrOfTargetChangedConnections() const { return m_nrOfTargetChangedConnections; } 00679 int nrOfConnections() const { return m_nrOfStatusChangedConnections + m_nrOfTargetChangedConnections; } 00681 QVector<int> m_currentStatus; 00682 QVector<double> m_currentPos; 00683 QVector<double> m_targetPos; 00685 00686 bool isMotorMoving() const 00687 { 00688 foreach(const int &i, m_currentStatus) 00689 { 00690 if (i & ito::actuatorMoving) return true; 00691 } 00692 return false; 00693 } 00694 00695 void sendStatusUpdate(const bool statusOnly = false); 00696 void sendTargetUpdate(); 00697 00699 00703 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; 00704 00706 00716 inline void setStatus(int &status, const int newFlags, const int keepMask = 0) { status = (status & keepMask) | newFlags; } 00717 00719 00729 inline void setStatus(const QVector<int> &axis, const int newFlags, const int keepMask = 0) 00730 { 00731 foreach(const int &i, axis) 00732 { 00733 setStatus(m_currentStatus[i], newFlags, keepMask); 00734 } 00735 } 00736 00738 00747 inline void replaceStatus(int &status, const int existingFlag, const int replaceFlag) { if (status & existingFlag) { status = (status ^ existingFlag) | replaceFlag; } } 00748 00750 00760 inline void replaceStatus(const QVector<int> &axis, const int existingFlag, const int replaceFlag) 00761 { 00762 foreach(const int &i, axis) 00763 { 00764 replaceStatus(m_currentStatus[i], existingFlag, replaceFlag); 00765 } 00766 } 00767 00769 00775 bool isInterrupted() 00776 { 00777 // QMutexLocker locker(&m_interruptMutex); 00778 bool res = m_interruptFlag; 00779 m_interruptFlag = false; 00780 return res; 00781 } 00782 00783 public: 00785 00792 void setInterrupt() 00793 { 00794 // QMutexLocker locker(&m_interruptMutex); 00795 m_interruptFlag = true; 00796 } 00797 00798 00799 00800 signals: 00802 00811 void actuatorStatusChanged(QVector<int> status, QVector<double> actPosition); 00812 00814 00822 void targetChanged(QVector<double> targetPositions); 00823 00824 public slots: 00826 virtual ito::RetVal calib(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00828 virtual ito::RetVal calib(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00830 virtual ito::RetVal setOrigin(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00832 virtual ito::RetVal setOrigin(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00834 virtual ito::RetVal getStatus(QSharedPointer<QVector<int> > status, ItomSharedSemaphore *waitCond) = 0; 00836 virtual ito::RetVal getPos(const int axis, QSharedPointer<double> pos, ItomSharedSemaphore *waitCond) = 0; 00838 virtual ito::RetVal getPos(const QVector<int> axis, QSharedPointer<QVector<double> > pos, ItomSharedSemaphore *waitCond) = 0; 00840 virtual ito::RetVal setPosAbs(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00842 virtual ito::RetVal setPosAbs(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00844 virtual ito::RetVal setPosRel(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00846 virtual ito::RetVal setPosRel(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00847 00848 }; 00849 00850 //---------------------------------------------------------------------------------------------------------------------------------- 00859 class AddInAlgo : public AddInBase 00860 { 00861 Q_OBJECT 00862 00863 Q_ENUMS(tAlgoCategory) 00864 Q_ENUMS(tAlgoInterface) 00865 00866 private: 00867 Q_DISABLE_COPY(AddInAlgo) 00868 00869 public: 00870 typedef ito::RetVal (* t_filter)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, QVector<ito::ParamBase> *paramsOut); 00871 typedef QWidget* (* t_algoWidget)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ito::RetVal &retValue); 00872 typedef ito::RetVal (* t_filterParam)(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut); 00873 00875 enum tAlgoCategory 00876 { 00877 catNone = 0x0000, 00878 catDiskIO = 0x0001, 00879 catAnalyseDataObject = 0x0002, 00880 catPlotDataObject = 0x0004 00881 }; 00882 00884 enum tAlgoInterface 00885 { 00886 iNotSpecified = 0x0000, 00887 iReadDataObject = 0x0001, 00888 iWriteDataObject = 0x0002, 00889 iReadPointCloud = 0x0004, 00890 iWritePointCloud = 0x0008, 00891 iReadPolygonMesh = 0x0010, 00892 iWritePolygonMesh = 0x0020, 00893 iPlotSingleObject = 0x0040 00894 }; 00895 00897 class FilterDef 00898 { 00899 public: 00901 FilterDef() : 00902 m_filterFunc(NULL), 00903 m_paramFunc(NULL), 00904 m_pBasePlugin(NULL), 00905 m_category(ito::AddInAlgo::catNone), 00906 m_interface(ito::AddInAlgo::iNotSpecified) 00907 {} 00908 00910 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()) : 00911 m_filterFunc(filterFunc), 00912 m_paramFunc(filterParamFunc), 00913 m_pBasePlugin(NULL), 00914 m_description(description), 00915 m_category(category), 00916 m_interface(interf), 00917 m_interfaceMeta(interfaceMeta) 00918 {} 00919 00920 virtual ~FilterDef() {} 00921 00922 t_filter m_filterFunc; 00923 t_filterParam m_paramFunc; 00924 ito::AddInInterfaceBase *m_pBasePlugin; 00925 QString m_name; 00926 QString m_description; 00927 ito::AddInAlgo::tAlgoCategory m_category; 00928 ito::AddInAlgo::tAlgoInterface m_interface; 00929 QString m_interfaceMeta; 00930 private: 00931 FilterDef (const FilterDef & /*p*/); //disable copy constructor 00932 }; 00933 00935 class AlgoWidgetDef 00936 { 00937 public: 00939 AlgoWidgetDef() : 00940 m_widgetFunc(NULL), 00941 m_paramFunc(NULL), 00942 m_pBasePlugin(NULL), 00943 m_category(ito::AddInAlgo::catNone), 00944 m_interface(ito::AddInAlgo::iNotSpecified) 00945 {} 00946 00948 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()) : 00949 m_widgetFunc(algoWidgetFunc), 00950 m_paramFunc(algoWidgetParamFunc), 00951 m_pBasePlugin(NULL), 00952 m_description(description), 00953 m_category(category), 00954 m_interface(interf), 00955 m_interfaceMeta(interfaceMeta) 00956 {} 00957 00958 virtual ~AlgoWidgetDef() {} 00959 00960 t_algoWidget m_widgetFunc; 00961 t_filterParam m_paramFunc; 00962 ito::AddInInterfaceBase *m_pBasePlugin; 00963 QString m_name; 00964 QString m_description; 00965 ito::AddInAlgo::tAlgoCategory m_category; 00966 ito::AddInAlgo::tAlgoInterface m_interface; 00967 QString m_interfaceMeta; 00968 00969 private: 00970 AlgoWidgetDef (const AlgoWidgetDef & /*p*/); //disable copy constructor 00971 }; 00972 00973 ito::RetVal getFilterList(QHash<QString, FilterDef *> &fList) const; 00974 ito::RetVal getAlgoWidgetList(QHash<QString, AlgoWidgetDef *> &awList) const; 00975 ito::RetVal rejectFilter(const QString &name); 00976 ito::RetVal rejectAlgoWidget(const QString &name); 00977 00978 protected: 00979 virtual ~AddInAlgo(); 00980 AddInAlgo(); 00981 QHash<QString, FilterDef *> m_filterList; 00982 QHash<QString, AlgoWidgetDef *> m_algoWidgetList; 00983 00984 static ito::RetVal prepareParamVectors(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut) 00985 { 00986 if (!paramsMand) return RetVal(ito::retError, 0, tr("uninitialized vector for mandatory parameters!").toAscii().data()); 00987 if (!paramsOpt) return RetVal(ito::retError, 0, tr("uninitialized vector for optional parameters!").toAscii().data()); 00988 if (!paramsOut) return RetVal(ito::retError, 0, tr("uninitialized vector for output parameters!").toAscii().data()); 00989 paramsMand->clear(); 00990 paramsOpt->clear(); 00991 paramsOut->clear(); 00992 return ito::retOk; 00993 } 00994 00995 public slots: 00996 virtual ito::RetVal getParam(QSharedPointer<ito::Param> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 00997 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 00998 }; 00999 01000 //---------------------------------------------------------------------------------------------------------------------------------- 01001 } // namespace ito 01002 01003 //########################################################################################################### 01004 // Interface version: 01005 //########################################################################################################### 01006 // 01007 // 01008 // Please change the interface version, if you made any changes to this interface, files located in the common folder or to the dataObject. 01009 // 01010 // To add a new version, do the following steps 01011 // 01012 // 1. append the string behind the variable ito_AddInInterface_CurrentVersion (e.g. ito.AddIn.InterfaceBase/1.1) to the array ito_AddInInterface_OldVersions 01013 // 2. change the version number in the string ito_AddInInterface_CurrentVersion 01014 // 01015 // 01016 // This helps, that deprecated or "future" plugins, which fit not to the current implementation of the interface will not be loaded 01017 // but a sophisticated error message is shown. 01018 01019 static const char* ito_AddInInterface_OldVersions[] = { 01020 "ito.AddIn.InterfaceBase/1.0", //version from start of development until 2012-10-11 01021 "ito.AddIn.InterfaceBase/1.1", //version until 2012-10-15 (outdated due to changes in dataObject) 01022 "ito.AddIn.InterfaceBase/1.1.1", //version until 2012-10-21 (outdated due to small changes in addInInterface) 01023 "ito.AddIn.InterfaceBase/1.1.2", //version until 2012-10-30 (outdated due to small changes in addInInterface) 01024 "ito.AddIn.InterfaceBase/1.1.3", //version until 2012-11-09 (outdated due to changes in the checkData()-function in addInGrabber) 01025 "ito.AddIn.InterfaceBase/1.1.4", //version until 2012-11-12 (outdated due to changes in the DataObject) 01026 "ito.AddIn.InterfaceBase/1.1.5", //version until 2012-11-18 (outdated: changes in the API structure) 01027 "ito.AddIn.InterfaceBase/1.1.6", //version until 2012-12-20 (outdated: added paramBase metatype) 01028 "ito.AddIn.InterfaceBase/1.1.7", //version until 2013-01-17 (outdated: last version for itom version 1.0.5) 01029 "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) 01030 "ito.AddIn.InterfaceBase/1.1.9", //version until 2013-03-04 (outdated: changes in dataObjectHelper) 01031 "ito.AddIn.InterfaceBase/1.1.10",//version until 2013-03-12 (outdated: Added license and about string to the plugin) 01032 "ito.AddIn.InterfaceBase/1.1.11",//version until 2013-03-22 (outdated: bugfix in ito::ParamBase) 01033 "ito.AddIn.InterfaceBase/1.1.12",//version until 2013-03-25 (outdated: changes in api) 01034 "ito.AddIn.InterfaceBase/1.1.13",//version until 2013-04-08 (outdated: removed transpose flag in dataObject) 01035 "ito.AddIn.InterfaceBase/1.1.14",//version until 2013-04-17 (outdated: uniqueID and identifier inserted/changed) 01036 "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)) 01037 "ito.AddIn.InterfaceBase/1.1.16",//version until 2013-06-07 (outdated: added qpluginloader to the interface for cleaner unloading of plugins) 01038 "ito.AddIn.InterfaceBase/1.1.17",//version until 2013-06-11 (outdated: apis extended, changes in param-class) 01039 "ito.AddIn.InterfaceBase/1.1.18",//version until 2013-06-18 (outdated: iterator and constIterator introduced for dataObject) 01040 "ito.AddIn.InterfaceBase/1.1.19",//version until 2013-08-15 (outdated: operators +, +=, -, -= introduced for scalar operands) 01041 "ito.AddIn.InterfaceBase/1.1.20",//version until 2013-10-10 (outdated: RGBA-type introduced into dataObjectTypes) 01042 "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) 01043 "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) 01044 "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) 01045 NULL 01046 }; 01047 01048 static const char* ito_AddInInterface_CurrentVersion = "ito.AddIn.InterfaceBase/1.1.24"; 01049 01051 Q_DECLARE_INTERFACE(ito::AddInInterfaceBase, ito_AddInInterface_CurrentVersion /*"ito.AddIn.InterfaceBase/1.1"*/) 01052 01053 #endif