itom 1.0.14
|
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 QVector<Param> paramsMand; 00105 QVector<Param> paramsOpt; 00106 QVector<Param> paramsOut; 00107 QString infoString; 00108 }; 00109 00110 struct FilterParams { 00111 QVector<Param> paramsMand; 00112 QVector<Param> paramsOpt; 00113 QVector<Param> paramsOut; 00114 }; 00115 00116 class AddInBase; 00117 class ActuatorAxis; 00118 class DataObject; 00119 00120 //---------------------------------------------------------------------------------------------------------------------------------- 00144 class AddInInterfaceBase : public QObject 00145 { 00146 Q_OBJECT 00147 00148 private: 00150 virtual ito::RetVal closeThisInst(ito::AddInBase **addInInst) = 0; 00151 00152 protected: 00153 int m_type; 00154 int m_version; 00155 QString m_filename; 00156 int m_maxItomVer; 00157 int m_minItomVer; 00158 QString m_author; 00159 QString m_description; 00160 QString m_detaildescription; 00161 QString m_license; 00162 QString m_aboutThis; 00163 QList<ito::AddInBase *> m_InstList; 00164 QVector<ito::Param> m_initParamsMand; 00165 QVector<ito::Param> m_initParamsOpt; 00166 //bool m_enableAutoLoad; //* Varialbe to enable autoload for plugin. Standard value is false. Must be overwritten in AddInConstructor */ 00167 tAutoLoadPolicy m_autoLoadPolicy; 00168 tAutoSavePolicy m_autoSavePolicy; 00169 bool m_callInitInNewThread; 00170 QPluginLoader *m_loader; 00171 00172 public: 00173 void **m_apiFunctionsBasePtr; 00174 void **m_apiFunctionsGraphBasePtr; 00175 00176 virtual ~AddInInterfaceBase(); 00177 00179 AddInInterfaceBase() : 00180 m_type(0), m_version(CREATEVERSION(0,0,0)), m_filename(""), 00181 m_maxItomVer(MAXVERSION), m_minItomVer(MINVERSION), 00182 m_author(""), m_description(""), m_detaildescription(""), m_license("LGPL with ITO itom-exception"), m_aboutThis(""), 00183 /*m_enableAutoLoad(false),*/ m_autoLoadPolicy(ito::autoLoadNever), 00184 m_autoSavePolicy(ito::autoSaveNever), m_callInitInNewThread(true), m_apiFunctionsBasePtr(NULL), m_apiFunctionsGraphBasePtr(NULL), m_loader(NULL) 00185 { } 00186 00188 inline int getType(void) const { return m_type; } 00190 inline int getVersion(void) const { return m_version; } 00192 inline int getMinItomVer(void) const { return m_minItomVer; } 00194 inline int getMaxItomVer(void) const { return m_maxItomVer; } 00195 00197 inline bool getCallInitInNewThread(void) const { return m_callInitInNewThread; } 00198 00200 inline tAutoLoadPolicy getAutoLoadPolicy(void) const { return m_autoLoadPolicy; } 00201 00203 inline tAutoSavePolicy getAutoSavePolicy(void) const { return m_autoSavePolicy; } 00204 00206 const QString getAuthor(void) const { return m_author; } 00208 const QString getDescription(void) const { return m_description; } 00210 const QString getDetailDescription(void) const { return m_detaildescription; } 00212 const QString getLicenseInfo(void) const { return m_license; } 00214 const QString getAboutInfo(void) const { return m_aboutThis; } 00216 const QString getFilename(void) const { return m_filename; } 00217 00218 const ito::RetVal setFilename(const QString &name ) { m_filename = name; return ito::retOk; } 00220 inline QList<ito::AddInBase *> getInstList(void) { return m_InstList; } 00221 inline const QList<ito::AddInBase *> getInstList(void) const { return m_InstList; } 00223 ito::RetVal closeInst(ito::AddInBase **addInInst); 00225 virtual QVector<ito::Param>* getInitParamsMand(void) { return &m_initParamsMand; } 00227 virtual QVector<ito::Param>* getInitParamsOpt(void) { return &m_initParamsOpt; } 00229 virtual ito::RetVal getAddInInst(ito::AddInBase **addInInst) = 0; 00231 void incRef(ito::AddInBase *addIn); 00233 void decRef(ito::AddInBase *addIn); 00235 int getRef(ito::AddInBase *addIn); 00237 int getInstCount() { return m_InstList.length(); } 00239 void setApiFunctions(void **apiFunctions); 00240 void setApiFunctionsGraph(void ** apiFunctionsGraph); 00241 inline void setLoader(QPluginLoader *loader) { m_loader = loader; } 00242 inline QPluginLoader * getLoader(void) { return m_loader; } 00243 00244 bool event(QEvent *e); 00245 00246 //signals: 00247 00248 //public slots: 00249 }; 00250 00251 //---------------------------------------------------------------------------------------------------------------------------------- 00265 class AddInBase : public QObject 00266 { 00267 Q_OBJECT 00268 00269 public: 00270 00271 struct AddInRef { 00272 AddInRef() : type(-1), ptr(0) {} 00273 AddInRef(void *p, int t) : type(t), ptr(p) {} 00274 int type; 00275 void *ptr; 00276 }; 00277 00279 00296 const Param getParamRec(const QString name, bool *nameCheckOk = NULL) const 00297 { 00298 QRegExp rx("^([a-zA-Z]+\\w*)(\\[(\\d+)\\]){0,1}(:(.*)){0,1}$"); 00299 if(rx.indexIn(name) == -1) 00300 { 00301 if(nameCheckOk) *nameCheckOk = false; 00302 return Param(); 00303 } 00304 else 00305 { 00306 QStringList pname = rx.capturedTexts(); 00307 if (pname.length() > 1) 00308 { 00309 if(nameCheckOk) *nameCheckOk = true; 00310 ito::Param tempParam = m_params.value(pname[1]); 00311 if (pname[2].length()) 00312 tempParam.addNameSuffix(pname[2].toAscii().data()); 00313 if (pname[4].length()) 00314 tempParam.addNameSuffix(pname[4].toAscii().data()); 00315 return tempParam; //returns default constructor if value not available in m_params. Default constructor has member isValid() => false 00316 } 00317 } 00318 return Param(); 00319 } 00320 00322 inline AddInInterfaceBase* getBasePlugin(void) const { return m_pBasePlugin; } 00323 00325 inline ito::RetVal MoveToThread(void) 00326 { 00327 m_pThread = new QThread(); 00328 moveToThread(m_pThread); 00329 m_pThread->start(); 00330 return retOk; 00331 } 00332 00334 /* 00335 Use the method setParam in order to change any parameter. 00336 00337 \param paramNames [out]. The pointer contains a pointer to the map after the call of this function 00338 \return RetVal returns retOk. 00339 */ 00340 inline const ito::RetVal getParamList(QMap<QString, Param> **paramNames) { *paramNames = &m_params; return ito::retOk; } 00341 00343 /* 00344 \param [out] funcs is the pointer to a map, that points to the internal map of additional functions after the method-call. 00345 \return retOk 00346 \sa registerExecFunc 00347 */ 00348 inline const ito::RetVal getExecFuncList(QMap<QString, ExecFuncParams> **funcs) { *funcs = &m_execFuncList; return ito::retOk; } 00349 00351 inline int getID() const { return m_uniqueID; } 00352 00354 inline QString getIdentifier() const { return m_identifier; } 00355 00357 virtual int hasConfDialog(void); 00358 00360 virtual const ito::RetVal showConfDialog(void); 00361 00363 inline int createdByGUI() const { return m_createdByGUI; } 00364 00366 inline void setCreatedByGUI(int value) { m_createdByGUI = value; } 00367 00369 /* 00370 The reference counter is zero-based, hence, the value zero means that one reference is pointing to this instance 00371 */ 00372 inline int getRefCount(void) 00373 { 00374 return m_refCount; 00375 } 00376 00378 /* 00379 \sa getDockWidget 00380 */ 00381 inline bool hasDockWidget(void) const { return m_dockWidget ? true : false; } 00382 00384 /* 00385 \sa hasDockWidget 00386 */ 00387 inline QDockWidget* getDockWidget(void) const { return m_dockWidget; } 00388 00389 // doc in source 00390 virtual void dockWidgetDefaultStyle(bool &floating, bool &visible, Qt::DockWidgetArea &defaultArea) const; 00391 00393 /* 00394 Any time-consuming operation of the plugin should regularly set the alive-flag to true 00395 by calling setAlive. The state of this flag is returned by this method and afterwards 00396 reset to 0. This method is thread-safe. 00397 00398 \return current status of alive-flag (1 if "still alive", else 0) 00399 \sa setAlive 00400 */ 00401 int isAlive(void) 00402 { 00403 // QMutexLocker locker(&m_atomicMutex); 00404 int wasalive = m_alive; 00405 m_alive = 0; 00406 return wasalive; 00407 } 00408 00410 /* 00411 This method is thread-safe. 00412 00413 \sa isAlive 00414 */ 00415 void setAlive(void) 00416 { 00417 // QMutexLocker locker(&m_atomicMutex); 00418 m_alive = 1; 00419 } 00420 00422 bool isInitialized(void) 00423 { 00424 // QMutexLocker locker(&m_atomicMutex); 00425 return m_initialized; 00426 } 00427 00429 /* 00430 \param [in] initialized is the value to set 00431 */ 00432 void setInitialized(bool initialized) 00433 { 00434 // QMutexLocker locker(&m_atomicMutex); 00435 m_initialized = initialized; 00436 } 00437 00439 /* 00440 This vector contains all plugin-instances, that have been passed to the init 00441 method of this plugin. The reference counter of these plugin is incremented at 00442 initialization of this plugin and decremented if this plugin will be destroyed. 00443 00444 \sa AddInRef, init 00445 */ 00446 QVector<ito::AddInBase::AddInRef *> * getArgAddIns(void) { return &m_hwDecList; } 00447 00448 protected: 00449 // constructor (doc in source) 00450 AddInBase(); 00451 00452 // destructor (doc in source) 00453 virtual ~AddInBase(); 00454 00455 //doc in source 00456 void createDockWidget(QString title, QDockWidget::DockWidgetFeatures features, Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas, QWidget *content = NULL); 00457 00458 // doc in source 00459 ito::RetVal registerExecFunc(const QString funcName, const QVector<ito::Param> ¶msMand, const QVector<ito::Param> ¶msOpt, const QVector<ito::Param> ¶msOut, const QString infoString); 00460 00462 inline void setBasePlugin(AddInInterfaceBase *base) { m_pBasePlugin = base; } 00463 00464 QThread *m_pThread; 00465 AddInInterfaceBase *m_pBasePlugin; 00466 QMap<QString, Param> m_params; 00467 00468 QString m_identifier; 00469 int m_refCount; 00470 int m_createdByGUI; 00471 QVector<ito::AddInBase::AddInRef *> m_hwDecList; 00472 QMap<QString, ExecFuncParams> m_execFuncList; 00473 00474 private: 00475 Q_DISABLE_COPY ( AddInBase ) 00476 00477 00478 inline void incRefCount(void) 00479 { 00480 m_refCountMutex.lock(); 00481 m_refCount++; 00482 m_refCountMutex.unlock(); 00483 } 00484 00486 inline void decRefCount(void) 00487 { 00488 m_refCountMutex.lock(); 00489 m_refCount--; 00490 m_refCountMutex.unlock(); 00491 } 00492 00493 int m_uniqueID; 00494 00495 QMutex m_refCountMutex; 00496 QDockWidget *m_dockWidget; 00497 int m_alive; 00498 QMutex m_atomicMutex; 00499 bool m_initialized; 00500 00501 friend class AddInInterfaceBase; 00502 00503 static int m_instCounter; 00504 00505 signals: 00507 00515 void parametersChanged(QMap<QString, ito::Param> params); 00516 00517 public slots: 00518 00520 virtual ito::RetVal init(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ItomSharedSemaphore *waitCond = NULL) = 0; 00522 virtual ito::RetVal close( ItomSharedSemaphore *waitCond) = 0; 00523 00525 virtual ito::RetVal getParam(QSharedPointer<ito::Param> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00527 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00528 00529 // doc in source-file 00530 ito::RetVal setParamVector(const QVector<QSharedPointer<ito::ParamBase> > values, ItomSharedSemaphore *waitCond = NULL); 00531 00532 // doc in source-file 00533 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); 00534 00535 00536 private slots: 00538 00545 void sendParameterRequest(){ emit parametersChanged(m_params); }; 00546 00548 00556 virtual void dockWidgetVisibilityChanged( bool /*visible*/ ) {}; 00557 00559 00564 void dockWidgetDestroyed() { m_dockWidget = NULL; } 00565 }; 00566 00567 //---------------------------------------------------------------------------------------------------------------------------------- 00594 class AddInDataIO : public AddInBase 00595 { 00596 Q_OBJECT 00597 00598 private: 00599 Q_DISABLE_COPY ( AddInDataIO ) 00600 00601 protected: 00602 virtual ~AddInDataIO() = 0; 00603 AddInDataIO(); 00604 00605 void runStatusChanged(bool deviceStarted); 00606 00607 //void timerEvent (QTimerEvent *event) = 0; //implement this event in your plugin, if you are a device, which is accessible by any liveImage!!! 00608 00609 QSet<QObject*> m_autoGrabbingListeners; 00610 int m_timerID; 00611 int m_timerIntervalMS; 00612 bool m_autoGrabbingEnabled; 00614 public: 00615 inline int getAutoGrabbing() { return m_autoGrabbingEnabled; } 00617 signals: 00618 00619 public slots: 00621 virtual ito::RetVal startDevice(ItomSharedSemaphore *waitCond); 00623 virtual ito::RetVal stopDevice(ItomSharedSemaphore *waitCond); 00625 virtual ito::RetVal acquire(const int trigger, ItomSharedSemaphore *waitCond = NULL); 00627 virtual ito::RetVal getVal(void* data, ItomSharedSemaphore *waitCond = NULL); 00629 virtual ito::RetVal getVal(QSharedPointer<char> data, QSharedPointer<int> length, ItomSharedSemaphore *waitCond = NULL); 00631 virtual ito::RetVal copyVal(void *dObj, ItomSharedSemaphore *waitCond); 00632 00634 virtual ito::RetVal setVal(const void *data, const int length, ItomSharedSemaphore *waitCond = NULL); 00635 00637 ito::RetVal enableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00638 00640 ito::RetVal disableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00641 00643 ito::RetVal startDeviceAndRegisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00644 00646 ito::RetVal stopDeviceAndUnregisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00647 }; 00648 00649 //---------------------------------------------------------------------------------------------------------------------------------- 00650 00651 00658 class AddInActuator : public AddInBase 00659 { 00660 Q_OBJECT 00661 00662 private: 00663 Q_DISABLE_COPY ( AddInActuator ) 00664 00665 int m_nrOfStatusChangedConnections; 00666 int m_nrOfTargetChangedConnections; 00667 bool m_interruptFlag; 00668 QMutex m_interruptMutex; 00670 protected: 00671 virtual ~AddInActuator() = 0; 00672 AddInActuator(); 00673 00674 virtual void connectNotify ( const char * signal ); 00675 virtual void disconnectNotify ( const char * signal ); 00676 int nrOfStatusChangedConnections() const { return m_nrOfStatusChangedConnections; } 00677 int nrOfTargetChangedConnections() const { return m_nrOfTargetChangedConnections; } 00678 int nrOfConnections() const { return m_nrOfStatusChangedConnections + m_nrOfTargetChangedConnections; } 00680 QVector<int> m_currentStatus; 00681 QVector<double> m_currentPos; 00682 QVector<double> m_targetPos; 00684 00685 bool isMotorMoving() const 00686 { 00687 foreach(const int &i, m_currentStatus) 00688 { 00689 if(i & ito::actuatorMoving) return true; 00690 } 00691 return false; 00692 } 00693 00694 void sendStatusUpdate(const bool statusOnly = false); 00695 void sendTargetUpdate(); 00696 00698 00702 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; 00703 00705 00715 inline void setStatus(int &status, const int newFlags, const int keepMask = 0) { status = (status & keepMask) | newFlags; } 00716 00718 00728 inline void setStatus(const QVector<int> &axis, const int newFlags, const int keepMask = 0) 00729 { 00730 foreach(const int &i, axis) 00731 { 00732 setStatus(m_currentStatus[i], newFlags, keepMask); 00733 } 00734 } 00735 00737 00746 inline void replaceStatus(int &status, const int existingFlag, const int replaceFlag) { if (status & existingFlag) { status = (status ^ existingFlag) | replaceFlag; } } 00747 00749 00759 inline void replaceStatus(const QVector<int> &axis, const int existingFlag, const int replaceFlag) 00760 { 00761 foreach(const int &i, axis) 00762 { 00763 replaceStatus(m_currentStatus[i], existingFlag, replaceFlag); 00764 } 00765 } 00766 00768 00774 bool isInterrupted() 00775 { 00776 // QMutexLocker locker(&m_interruptMutex); 00777 bool res = m_interruptFlag; 00778 m_interruptFlag = false; 00779 return res; 00780 } 00781 00782 public: 00784 00791 void setInterrupt() 00792 { 00793 // QMutexLocker locker(&m_interruptMutex); 00794 m_interruptFlag = true; 00795 } 00796 00797 00798 00799 signals: 00801 00810 void actuatorStatusChanged(QVector<int> status, QVector<double> actPosition); 00811 00813 00821 void targetChanged(QVector<double> targetPositions); 00822 00823 public slots: 00825 virtual ito::RetVal calib(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00827 virtual ito::RetVal calib(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00829 virtual ito::RetVal setOrigin(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00831 virtual ito::RetVal setOrigin(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00833 virtual ito::RetVal getStatus(QSharedPointer<QVector<int> > status, ItomSharedSemaphore *waitCond) = 0; 00835 virtual ito::RetVal getPos(const int axis, QSharedPointer<double> pos, ItomSharedSemaphore *waitCond) = 0; 00837 virtual ito::RetVal getPos(const QVector<int> axis, QSharedPointer<QVector<double> > pos, ItomSharedSemaphore *waitCond) = 0; 00839 virtual ito::RetVal setPosAbs(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00841 virtual ito::RetVal setPosAbs(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00843 virtual ito::RetVal setPosRel(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00845 virtual ito::RetVal setPosRel(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00846 00847 }; 00848 00849 //---------------------------------------------------------------------------------------------------------------------------------- 00858 class AddInAlgo : public AddInBase 00859 { 00860 Q_OBJECT 00861 00862 Q_ENUMS(tAlgoCategory) 00863 Q_ENUMS(tAlgoInterface) 00864 00865 private: 00866 Q_DISABLE_COPY( AddInAlgo ) 00867 00868 public: 00869 typedef ito::RetVal (* t_filter)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, QVector<ito::ParamBase> *paramsOut); 00870 typedef QWidget* (* t_algoWidget)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ito::RetVal &retValue); 00871 typedef ito::RetVal (* t_filterParam)(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut); 00872 00874 enum tAlgoCategory 00875 { 00876 catNone = 0x0000, 00877 catDiskIO = 0x0001, 00878 catAnalyseDataObject = 0x0002, 00879 catPlotDataObject = 0x0004 00880 }; 00881 00883 enum tAlgoInterface 00884 { 00885 iNotSpecified = 0x0000, 00886 iReadDataObject = 0x0001, 00887 iWriteDataObject = 0x0002, 00888 iReadPointCloud = 0x0004, 00889 iWritePointCloud = 0x0008, 00890 iReadPolygonMesh = 0x0010, 00891 iWritePolygonMesh = 0x0020, 00892 iPlotSingleObject = 0x0040 00893 }; 00894 00896 class FilterDef 00897 { 00898 public: 00900 FilterDef() : 00901 m_filterFunc(NULL), 00902 m_paramFunc(NULL), 00903 m_pBasePlugin(NULL), 00904 m_category(ito::AddInAlgo::catNone), 00905 m_interface(ito::AddInAlgo::iNotSpecified) 00906 {} 00907 00909 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()) : 00910 m_filterFunc(filterFunc), 00911 m_paramFunc(filterParamFunc), 00912 m_pBasePlugin(NULL), 00913 m_description(description), 00914 m_category(category), 00915 m_interface(interf), 00916 m_interfaceMeta(interfaceMeta) 00917 {} 00918 00919 virtual ~FilterDef() {} 00920 00921 t_filter m_filterFunc; 00922 t_filterParam m_paramFunc; 00923 ito::AddInInterfaceBase *m_pBasePlugin; 00924 QString m_name; 00925 QString m_description; 00926 ito::AddInAlgo::tAlgoCategory m_category; 00927 ito::AddInAlgo::tAlgoInterface m_interface; 00928 QString m_interfaceMeta; 00929 private: 00930 FilterDef ( const FilterDef & /*p*/ ); //disable copy constructor 00931 }; 00932 00934 class AlgoWidgetDef 00935 { 00936 public: 00938 AlgoWidgetDef() : 00939 m_widgetFunc(NULL), 00940 m_paramFunc(NULL), 00941 m_pBasePlugin(NULL), 00942 m_category(ito::AddInAlgo::catNone), 00943 m_interface(ito::AddInAlgo::iNotSpecified) 00944 {} 00945 00947 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()) : 00948 m_widgetFunc(algoWidgetFunc), 00949 m_paramFunc(algoWidgetParamFunc), 00950 m_pBasePlugin(NULL), 00951 m_description(description), 00952 m_category(category), 00953 m_interface(interf), 00954 m_interfaceMeta(interfaceMeta) 00955 {} 00956 00957 virtual ~AlgoWidgetDef() {} 00958 00959 t_algoWidget m_widgetFunc; 00960 t_filterParam m_paramFunc; 00961 ito::AddInInterfaceBase *m_pBasePlugin; 00962 QString m_name; 00963 QString m_description; 00964 ito::AddInAlgo::tAlgoCategory m_category; 00965 ito::AddInAlgo::tAlgoInterface m_interface; 00966 QString m_interfaceMeta; 00967 00968 private: 00969 AlgoWidgetDef ( const AlgoWidgetDef & /*p*/ ); //disable copy constructor 00970 }; 00971 00972 ito::RetVal getFilterList(QHash<QString, FilterDef *> &fList) const; 00973 ito::RetVal getAlgoWidgetList(QHash<QString, AlgoWidgetDef *> &awList) const; 00974 ito::RetVal rejectFilter(const QString &name); 00975 ito::RetVal rejectAlgoWidget(const QString &name); 00976 00977 protected: 00978 virtual ~AddInAlgo(); 00979 AddInAlgo(); 00980 QHash<QString, FilterDef *> m_filterList; 00981 QHash<QString, AlgoWidgetDef *> m_algoWidgetList; 00982 00983 static ito::RetVal prepareParamVectors(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut) 00984 { 00985 if (!paramsMand) return RetVal(ito::retError, 0, tr("uninitialized vector for mandatory parameters!").toAscii().data()); 00986 if (!paramsOpt) return RetVal(ito::retError, 0, tr("uninitialized vector for optional parameters!").toAscii().data()); 00987 if (!paramsOut) return RetVal(ito::retError, 0, tr("uninitialized vector for output parameters!").toAscii().data()); 00988 paramsMand->clear(); 00989 paramsOpt->clear(); 00990 paramsOut->clear(); 00991 return ito::retOk; 00992 } 00993 00994 public slots: 00995 virtual ito::RetVal getParam(QSharedPointer<ito::Param> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 00996 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 00997 }; 00998 00999 //---------------------------------------------------------------------------------------------------------------------------------- 01000 } // namespace ito 01001 01002 //########################################################################################################### 01003 // Interface version: 01004 //########################################################################################################### 01005 // 01006 // 01007 // Please change the interface version, if you made any changes to this interface, files located in the common folder or to the dataObject. 01008 // 01009 // To add a new version, do the following steps 01010 // 01011 // 1. append the string behind the variable ito_AddInInterface_CurrentVersion (e.g. ito.AddIn.InterfaceBase/1.1) to the array ito_AddInInterface_OldVersions 01012 // 2. change the version number in the string ito_AddInInterface_CurrentVersion 01013 // 01014 // 01015 // This helps, that deprecated or "future" plugins, which fit not to the current implementation of the interface will not be loaded 01016 // but a sophisticated error message is shown. 01017 01018 static const char* ito_AddInInterface_OldVersions[] = { 01019 "ito.AddIn.InterfaceBase/1.0", //version from start of development until 2012-10-11 01020 "ito.AddIn.InterfaceBase/1.1", //version until 2012-10-15 (outdated due to changes in dataObject) 01021 "ito.AddIn.InterfaceBase/1.1.1", //version until 2012-10-21 (outdated due to small changes in addInInterface) 01022 "ito.AddIn.InterfaceBase/1.1.2", //version until 2012-10-30 (outdated due to small changes in addInInterface) 01023 "ito.AddIn.InterfaceBase/1.1.3", //version until 2012-11-09 (outdated due to changes in the checkData()-function in addInGrabber) 01024 "ito.AddIn.InterfaceBase/1.1.4", //version until 2012-11-12 (outdated due to changes in the DataObject) 01025 "ito.AddIn.InterfaceBase/1.1.5", //version until 2012-11-18 (outdated: changes in the API structure) 01026 "ito.AddIn.InterfaceBase/1.1.6", //version until 2012-12-20 (outdated: added paramBase metatype) 01027 "ito.AddIn.InterfaceBase/1.1.7", //version until 2013-01-17 (outdated: last version for itom version 1.0.5) 01028 "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) 01029 "ito.AddIn.InterfaceBase/1.1.9", //version until 2013-03-04 (outdated: changes in dataObjectHelper) 01030 "ito.AddIn.InterfaceBase/1.1.10",//version until 2013-03-12 (outdated: Added license and about string to the plugin) 01031 "ito.AddIn.InterfaceBase/1.1.11",//version until 2013-03-22 (outdated: bugfix in ito::ParamBase) 01032 "ito.AddIn.InterfaceBase/1.1.12",//version until 2013-03-25 (outdated: changes in api) 01033 "ito.AddIn.InterfaceBase/1.1.13",//version until 2013-04-08 (outdated: removed transpose flag in dataObject) 01034 "ito.AddIn.InterfaceBase/1.1.14",//version until 2013-04-17 (outdated: uniqueID and identifier inserted/changed) 01035 "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)) 01036 "ito.AddIn.InterfaceBase/1.1.16",//version until 2013-06-07 (outdated: added qpluginloader to the interface for cleaner unloading of plugins) 01037 "ito.AddIn.InterfaceBase/1.1.17",//version until 2013-06-11 (outdated: apis extended, changes in param-class) 01038 "ito.AddIn.InterfaceBase/1.1.18",//version until 2013-06-18 (outdated: iterator and constIterator introduced for dataObject) 01039 "ito.AddIn.InterfaceBase/1.1.19",//version until 2013-08-15 (outdated: operators +, +=, -, -= introduced for scalar operands) 01040 NULL 01041 }; 01042 01043 static const char* ito_AddInInterface_CurrentVersion = "ito.AddIn.InterfaceBase/1.1.20"; 01044 01046 Q_DECLARE_INTERFACE(ito::AddInInterfaceBase, ito_AddInInterface_CurrentVersion /*"ito.AddIn.InterfaceBase/1.1"*/) 01047 01048 #endif